diff options
Diffstat (limited to 'eval.c')
-rw-r--r-- | eval.c | 54 |
1 files changed, 54 insertions, 0 deletions
@@ -9120,6 +9120,57 @@ method_unbind(obj) /* * call-seq: + * meth.receiver => object + * + * Returns the bound receiver of the method object. + */ + +static VALUE +method_receiver(obj) + VALUE obj; +{ + struct METHOD *data; + + Data_Get_Struct(obj, struct METHOD, data); + return data->recv; +} + +/* + * call-seq: + * meth.name => string + * + * Returns the name of the method. + */ + +static VALUE +method_name(obj) + VALUE obj; +{ + struct METHOD *data; + + Data_Get_Struct(obj, struct METHOD, data); + return rb_str_new2(rb_id2name(data->oid)); +} + +/* + * call-seq: + * meth.owner => class_or_module + * + * Returns the class or module that defines the method. + */ + +static VALUE +method_owner(obj) + VALUE obj; +{ + struct METHOD *data; + + Data_Get_Struct(obj, struct METHOD, data); + return data->klass; +} + +/* + * call-seq: * obj.method(sym) => method * * Looks up the named method as a receiver in <i>obj</i>, returning a @@ -9739,6 +9790,9 @@ Init_Proc() rb_define_method(rb_cMethod, "inspect", method_inspect, 0); rb_define_method(rb_cMethod, "to_s", method_inspect, 0); rb_define_method(rb_cMethod, "to_proc", method_proc, 0); + rb_define_method(rb_cMethod, "receiver", method_receiver, 0); + rb_define_method(rb_cMethod, "name", method_name, 0); + rb_define_method(rb_cMethod, "owner", method_owner, 0); rb_define_method(rb_cMethod, "unbind", method_unbind, 0); rb_define_method(rb_mKernel, "method", rb_obj_method, 1); |