to_proc()
public
Returns a Proc object corresponding to this
method.
Show source
static VALUE
method_proc(VALUE method)
{
VALUE procval;
struct METHOD *meth;
rb_proc_t *proc;
rb_env_t *env;
/*
* class Method
* def to_proc
* proc{|*args|
* self.call(*args)
* }
* end
* end
*/
TypedData_Get_Struct(method, struct METHOD, &method_data_type, meth);
procval = rb_iterate(mlambda, 0, bmcall, method);
GetProcPtr(procval, proc);
proc->is_from_method = 1;
proc->block.self = meth->recv;
proc->block.klass = meth->defined_class;
GetEnvPtr(proc->envval, env);
env->block.self = meth->recv;
env->block.klass = meth->defined_class;
env->block.iseq = method_get_iseq(meth->me->def);
return procval;
}