It forwards the message (method call request) received by the object to the appropriate class.
Say you have a class
class MyClass def MyClass.current_section puts "I'm the class method." end def current_section self.class.current_section end end h = MyClass.new h.current_section
Calling the h method, it searches for the class h ( MyClass ) and calls the current_section method of this class.
Thus, according to the above definitions, each object of the MyClass class has a current_section method, which is directed to the central current_section this class.
Defining class methods in your question is simply using a different syntax for this: adding a method to a class object.
source share