Skip to content
Permalink
Browse files
implement Proc#for_define_method
  • Loading branch information
tak1n committed Feb 5, 2016
1 parent d436251 commit 040c7262f45242986e984e82824e04b666d32f41
Showing with 21 additions and 15 deletions.
  1. +1 −15 core/module.rb
  2. +20 −0 core/proc.rb
@@ -444,21 +444,7 @@ def define_method(name, meth = undefined, &prc)

case meth
when Proc
if meth.ruby_method
code = Rubinius::DelegatedMethod.new(name, :call, meth, false)
if meth.ruby_method.executable.kind_of? Rubinius::CompiledCode
scope = meth.ruby_method.executable.scope
else
scope = nil
end
else
be = meth.block.dup
be.change_name name
code = Rubinius::BlockEnvironment::AsMethod.new(be)
meth = meth.dup
meth.lambda_style!
scope = meth.block.scope
end
code, scope = meth.for_define_method(name)
when Method
Rubinius::Type.bindable_method? meth.defined_in, self.class

@@ -244,6 +244,26 @@ def dup
copy
end

def for_define_method(name)
if @ruby_method
code = Rubinius::DelegatedMethod.new(name, :call, self, false)
if @ruby_method.executable.kind_of? Rubinius::CompiledCode
scope = @ruby_method.executable.scope
else
scope = nil
end
else
be = @block.dup
be.change_name name
code = Rubinius::BlockEnvironment::AsMethod.new(be)
meth = self.dup
meth.lambda_style!
scope = meth.block.scope
end

[code, scope]
end

def self.from_method(meth)
if meth.kind_of? Method
return __from_method__(meth)

0 comments on commit 040c726

Please sign in to comment.