__method__()
public
Returns the name of the current method as a Symbol. If called from inside of an aliased method
it will return the original nonaliased name. If called outside of a method,
it returns nil.
def foo
__method__
end
alias bar foo
foo
bar
Show source
/*
* call-seq:
* __method__ => symbol
*
* Returns the name of the current method as a Symbol.
* If called from inside of an aliased method it will return the original
* nonaliased name.
* If called outside of a method, it returns <code>nil</code>.
*
* def foo
* __method__
* end
* alias bar foo
*
* foo
* bar
*
*/
static VALUE
rb_f_method_name()
{
struct FRAME* prev = ruby_frame->prev;
if (prev && prev->orig_func) {
return ID2SYM(prev->orig_func);
}
else {
return Qnil;
}
}