You can be notified whenever one of the following events occurs:
These techniques are all illustrated in the library descriptions for
each callback method. At runtime, these methods will be called by the
system when the specified event occurs. By default, these methods do
nothing. If you want to be notified when one of these events happens,
just define the callback method, and you're in.
Keeping track of method creation and class and module usage lets you
build an accurate picture of the dynamic state of your program. This
can be important. For example, you may have written code that wraps
all the methods in a class, perhaps to add transactional support or
to implement some form of delegation. This is only half the job: the
dynamic nature of Ruby means that users of this class could add new
methods to it at any time. Using these callbacks, you can write
code that wraps these new methods as they are created.