Skip to content

Commit

Permalink
raise TypeError if meth does not respond to :for_define_method
Browse files Browse the repository at this point in the history
  • Loading branch information
tak1n committed Feb 5, 2016
1 parent 3f9756b commit 510919d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion core/module.rb
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,11 @@ def define_method(name, meth = undefined, &prc)

name = Rubinius::Type.coerce_to_symbol name

code, scope = meth.for_define_method(name, self.class)
if meth.respond_to?(:for_define_method)
code, scope = meth.for_define_method(name, self.class)
else
raise TypeError, "wrong argument type #{meth.class} (expected Proc/Method)"
end

Rubinius.add_method name, code, self, scope, 0, :public

Expand Down

0 comments on commit 510919d

Please sign in to comment.