ActiveSupport::Callbacks

module ActiveSupport::Callbacks

Callbacks are code hooks that are run at key points in an object's life cycle. The typical use case is to have a base class define a set of callbacks relevant to the other functionality it supplies, so that subclasses can install callbacks that enhance or modify the base functionality without needing to override or redefine methods of the base class.

Mixing in this module allows you to define the events in the object's life cycle that will support callbacks (via ClassMethods.define_callbacks), set the instance methods, procs, or callback objects to be called (via ClassMethods.set_callback), and run the installed callbacks at the appropriate times (via run_callbacks).

Three kinds of callbacks are supported: before callbacks, run before a certain eve