Skip to content
Permalink
Browse files
Fix Module#define_method
When defining a method through a proc which gets created out of a method
which is defined in a C-ext, `meth.ruby_method.executable` is a instance of
Rubinius::NativeCode and not Rubinius::CompiledCode which does not
respond to #scope.

This is used for example in pg gem:
https://github.com/ged/ruby-pg/blob/bb4693e811f9348f202835e701e6509d15685b0a/lib/pg/connection.rb#L187
  • Loading branch information
tak1n committed Feb 5, 2016
1 parent 40f04c1 commit d43625161f4cd3d0acccea77c6b13ed160f06267
Showing with 5 additions and 1 deletion.
  1. +5 −1 core/module.rb
@@ -446,7 +446,11 @@ def define_method(name, meth = undefined, &prc)
when Proc
if meth.ruby_method
code = Rubinius::DelegatedMethod.new(name, :call, meth, false)
scope = meth.ruby_method.executable.scope
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

0 comments on commit d436251

Please sign in to comment.