CSC/ECE 517 Summer 2008/wiki1 5 bk
Understanding Hooks
The hooking mechanism in Ruby allows certain functional events in a program to be identified while providing an action that will occur upon detection of the specified event. In this way, hooks serve as a detector of actions within the code. Examples of where such a technique would prove useful include:
- Recording when or how many times a method is called.
- Recording when an object is created.