Module: DataMapper::CallbacksHelper
- Defined in:
- lib/data_mapper/callbacks.rb
Overview
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.
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
-
.included(base) ⇒ Object
The ::included callback extends the included class with a ::callbacks method, and sets up helper methods for the standard events declared in Callbacks::EVENTS.
Class Method Details
.included(base) ⇒ Object
The ::included callback extends the included class with a ::callbacks method, and sets up helper methods for the standard events declared in Callbacks::EVENTS.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/data_mapper/callbacks.rb', line 11 def self.included(base) base.extend(ClassMethods) # Declare helpers for the standard EVENTS Callbacks::EVENTS.each do |name| base.class_eval <<-EOS def self.#{name}(string = nil, &block) if string.nil? callbacks.add(:#{name}, block) else callbacks.add(:#{name}, string) end end EOS end end |