From: "jacknagel (Jack Nagel)" Date: 2013-04-18T03:17:15+09:00 Subject: [ruby-core:54404] [ruby-trunk - Bug #8284][Open] Expected behavior of Module#public_class_method Issue #8284 has been reported by jacknagel (Jack Nagel). ---------------------------------------- Bug #8284: Expected behavior of Module#public_class_method https://bugs.ruby-lang.org/issues/8284 Author: jacknagel (Jack Nagel) Status: Open Priority: Normal Assignee: Category: Target version: ruby -v: ruby 2.0.0p0 (2013-02-24 revision 39474) [i386-darwin10.8.0] It was pointed out by Myron Marston (here: https://gist.github.com/myronmarston/5401829) that calling public_class_method on an anonymous module makes the named method public on Object, etc. Object.define_method => NoMethodError Module.new.public_class_method(:define_method) Object.define_method => ArgumentError Also of note, the same is not true when calling it on a class: Object.define_method => NoMethodError Class.new.public_class_method(:define_method) Object.define_method => NoMethodError which seems inconsistent given: Module.new.singleton_class.ancestors => [Module, Object, Kernel, BasicObject] Class.new.singleton_class.ancestors => [Class, Module, Object, Kernel, BasicObject] Is this a bug or expected behavior? If the latter, what is the correct explanation? -- http://bugs.ruby-lang.org/