January 2024
Intermediate to advanced
718 pages
20h 15m
English
In Class Methods and Modules, we defined a method called included in our GeneralLogger module. When this module was included in a class, Ruby automatically invoked this included method, allowing our module to add class methods to the host class.
included is an example of a hook method (sometimes called a callback). A hook method is a method that you write but that Ruby calls from within the interpreter when some particular event occurs. The interpreter looks for these methods by name. If you define a method in the right context with an appropriate name, Ruby will call it when the corresponding event happens.
The methods that can be invoked from within the interpreter are:
method_added, method_missing ...
Read now
Unlock full access