Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Why does `public_class_method` in an anonymous module make the method public on `Object`?
➜ irb
1.9.3p327 :001 > Object.define_method
NoMethodError: private method `define_method' called for Object:Class
from (irb):1
from /Users/myron/.rvm/rubies/ruby-1.9.3-p327/bin/irb:16:in `<main>'
1.9.3p327 :002 > m = do
1.9.3p327 :003 > public_class_method :define_method
1.9.3p327 :004?> end
=> #<Module:0x007fd4c493d8e8>
1.9.3p327 :005 > Object.define_method
ArgumentError: wrong number of arguments (0 for 1)
from (irb):5:in `define_method'
from (irb):5
from /Users/myron/.rvm/rubies/ruby-1.9.3-p327/bin/irb:16:in `<main>'
1.9.3p327 :006 > exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.