a) Singleton methods are inserted into an anonymous class immediately
above the object in the method lookup chain.
b) The methods in an included module are also inserted in an anonymous
class immediately above the class/module that does the include()'ing.
One tricky part of the method lookup: class methods are inherited by
subclasses:
class Parent
def self.greet
puts 'Hi!'
end
end
class Child < Parent
def self.cry
puts 'Weeep, weep!'
end
end
Child.cry
Child.greet
--output:--
Weeep, weep!
Hi!
--
Posted via http://www.ruby-forum.com/.