public
Created

Why does `public_class_method` in an anonymous module make the method public on `Object`?

  • Download Gist
irb_session
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
➜ 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 = Module.new 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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.