I learning ruby singletons and have misunderstanding with such code:
class MyClass
def self.class_singleton_mymethod
end
end
class_singleton = class << MyClass
self
end
puts class_singleton.methods.grep(/mymethod/) # => []
obj = MyClass.new
def obj.object_singleton_mymethod
end
object_singleton = class << obj
self
end
puts object_singleton.methods.grep(/mymethod/) # => class_singleton_mymethod
Why class_singleton not contains class's Class method and object_singleton instead of Object's singleton method contains class's Class method?