Module DataMapper::CallbacksHelper
In: lib/data_mapper/callbacks.rb
lib/data_mapper/callbacks.rb

CallbacksHelper adds a class-method ClassMethods#callbacks when included in a class, and defines short-cut class-methods to add delegates to callbacks for the built-in Callbacks::EVENTS.

Methods

included   included  

Classes and Modules

Module DataMapper::CallbacksHelper::ClassMethods

Public Class methods

The ::included callback extends the included class with a ::callbacks method, and sets up helper methods for the standard events declared in Callbacks::EVENTS.

[Source]

    # File lib/data_mapper/callbacks.rb, line 11
11:     def self.included(base)
12:       base.extend(ClassMethods)
13:       
14:       # Declare helpers for the standard EVENTS
15:       Callbacks::EVENTS.each do |name|
16:         base.class_eval "def self.\#{name}(string = nil, &block)\nif string.nil?\ncallbacks.add(:\#{name}, block)\nelse\ncallbacks.add(:\#{name}, string)\nend\nend\n"
17:       end
18:     end

The ::included callback extends the included class with a ::callbacks method, and sets up helper methods for the standard events declared in Callbacks::EVENTS.

[Source]

    # File lib/data_mapper/callbacks.rb, line 11
11:     def self.included(base)
12:       base.extend(ClassMethods)
13:       
14:       # Declare helpers for the standard EVENTS
15:       Callbacks::EVENTS.each do |name|
16:         base.class_eval "def self.\#{name}(string = nil, &block)\nif string.nil?\ncallbacks.add(:\#{name}, block)\nelse\ncallbacks.add(:\#{name}, string)\nend\nend\n"
17:       end
18:     end

[Validate]