method

__callee__

v2_4_6 - Show latest stable - Class: Kernel
__callee__()
public

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

1Note

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

stevecj ยท Sep 10, 2012

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.