Method: Kernel#__method__

Defined in:
eval.c

#__method__Object

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

[View source]

1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
# File 'eval.c', line 1987

static VALUE
rb_f_method_name(VALUE _)
{
    ID fname = prev_frame_func(); /* need *method* ID */

    if (fname) {
        return ID2SYM(fname);
    }
    else {
        return Qnil;
    }
}