Flowdock
__callee__() public

Returns the name of the current method as a Symbol. If called outside of a method, it returns nil.

Show source
Register or log in to add new notes.
September 10, 2012
0 thanks

__callee__ and __method__ both return symbol when originally defined, not current

There has been some indication that __callee__ is intended to return the symbol with which the method was actually invoked, whereas __method__ returns name with which the method was originally defined, but __callee__ actually behaves identically to __method__ in Ruby 1.9.1 1.9.2, and 1.9.3.

This distinction is meaningful, because methods can be aliased after they are created.

In Ruby 1.8.7, it was possible (though) not convenient to get the name of the method as actually invoked, by calling another method that extracts the name from caller.first. Even that hack no longer works in Ruby 1.9 though, since it will return the originally defined method name as well.