Module: UltraMarathon::Callbacks::ClassMethods
- Includes:
- UltraMarathon::Contexticution
- Defined in:
- lib/ultra_marathon/callbacks.rb
Instance Method Summary collapse
-
#callbacks(*callback_names) ⇒ Object
Add one or more new callbacks for class E.g.
Methods included from UltraMarathon::Contexticution
Instance Method Details
#callbacks(*callback_names) ⇒ Object
Add one or more new callbacks for class E.g.
callbacks :after_save
Defines a class method ‘after_save` which takes an object responding to :call (Proc or lambda) or a symbol to be called in the context of the instance
Also defines ‘invoke_after_save_callbacks` instance method for designating when the callbacks should be invoked
42 43 44 45 46 47 48 49 50 |
# File 'lib/ultra_marathon/callbacks.rb', line 42 def callbacks(*callback_names) new_callbacks = Set.new(callback_names) - _callback_names new_callbacks.each do |callback_name| add_callbacks_accessor callback_name define_callback callback_name add_invoke_callback callback_name end self._callback_names = new_callbacks end |