Module: Lotus::Action::Callbacks::ClassMethods
- Defined in:
- lib/lotus/action/callbacks.rb
Overview
Class Method Summary collapse
-
.extended(base) ⇒ Object
private
Override Ruby’s hook for modules.
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
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Override Ruby’s hook for modules. It includes callbacks logic
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/lotus/action/callbacks.rb', line 38 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.
129 130 131 |
# File 'lib/lotus/action/callbacks.rb', line 129 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.
110 111 112 |
# File 'lib/lotus/action/callbacks.rb', line 110 def before(*callbacks, &blk) before_callbacks.add(*callbacks, &blk) end |