Module: Karafka::Web::Ui::Controllers::Requests::Hookable::ClassMethods
- Defined in:
- lib/karafka/web/ui/controllers/requests/hookable.rb
Overview
DSL methods for defining and inheriting hooks
Instance Method Summary collapse
-
#after(*actions, &block) { ... } ⇒ Object
Register an after hook.
-
#after_hooks ⇒ Array
Accumulated after hooks.
-
#before(*actions, &block) { ... } ⇒ Object
Register a before hook.
-
#before_hooks ⇒ Array
Accumulated before hooks.
-
#inherited(subclass) ⇒ Object
Inherit parent hooks into subclass.
Instance Method Details
#after(*actions, &block) { ... } ⇒ Object
Register an after hook
72 73 74 |
# File 'lib/karafka/web/ui/controllers/requests/hookable.rb', line 72 def after(*actions, &block) after_hooks << [actions, block] end |
#after_hooks ⇒ Array
Returns accumulated after hooks.
54 55 56 |
# File 'lib/karafka/web/ui/controllers/requests/hookable.rb', line 54 def after_hooks @after_hooks ||= [] end |
#before(*actions, &block) { ... } ⇒ Object
Register a before hook
63 64 65 |
# File 'lib/karafka/web/ui/controllers/requests/hookable.rb', line 63 def before(*actions, &block) before_hooks << [actions, block] end |
#before_hooks ⇒ Array
Returns accumulated before hooks.
49 50 51 |
# File 'lib/karafka/web/ui/controllers/requests/hookable.rb', line 49 def before_hooks @before_hooks ||= [] end |
#inherited(subclass) ⇒ Object
Inherit parent hooks into subclass
42 43 44 45 46 |
# File 'lib/karafka/web/ui/controllers/requests/hookable.rb', line 42 def inherited(subclass) super subclass.before_hooks.concat(before_hooks) subclass.after_hooks.concat(after_hooks) end |