This is the description of Kernel#__method__
according to Ruby-Doc.org (emphasis added):
Returns the name at the definition of the current method as a Symbol. If called outside of a method, it returns
nil
.
Now consider the following code snippet:
DEFINITION = proc { __method__ }
class C
define_method :one, DEFINITION
define_method :two, DEFINITION
end
o = C.new
When I run the following using MRI v1.8.7+ I'm getting the expected results:
o.one #=> :one
o.two #=> :two
However when I run the same code using JRuby 1.7+ (I haven't tested the previous versions):
o.one #=> :two
o.two #=> :two
Could this be considered a defect in JRuby's implementation or is it simply a different interpretation of Kernel#__method__
?