Module: Lotus::Action::Callbacks::ClassMethods
- Defined in:
- lib/lotus/action/callbacks.rb
Overview
Class Method Summary collapse
Instance Method Summary collapse
-
#after(*callbacks, &blk) ⇒ void
Define a callback for an Action.
-
#before(*callbacks, &blk) ⇒ void
Define a callback for an Action.
Class Method Details
.extended(base) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/lotus/action/callbacks.rb', line 20 def self.extended(base) base.class_eval do include Utils::ClassAttribute class_attribute :before_callbacks self.before_callbacks = Utils::Callbacks::Chain.new class_attribute :after_callbacks self.after_callbacks = Utils::Callbacks::Chain.new end end |
Instance Method Details
#after(*callbacks, &blk) ⇒ void
This method returns an undefined value.
Define a callback for an Action. The callback will be executed after the action is called, in the order they are added.
111 112 113 |
# File 'lib/lotus/action/callbacks.rb', line 111 def after(*callbacks, &blk) after_callbacks.add *callbacks, &blk end |
#before(*callbacks, &blk) ⇒ void
This method returns an undefined value.
Define a callback for an Action. The callback will be executed before the action is called, in the order they are added.
92 93 94 |
# File 'lib/lotus/action/callbacks.rb', line 92 def before(*callbacks, &blk) before_callbacks.add *callbacks, &blk end |