Class: Brute::Hooks::Composite
Overview
Composes multiple hooks into one, firing them in order.
Instance Method Summary collapse
- #<<(hook) ⇒ Object
- #call(event, **data) ⇒ Object
-
#initialize(*hooks) ⇒ Composite
constructor
A new instance of Composite.
Constructor Details
#initialize(*hooks) ⇒ Composite
Returns a new instance of Composite.
36 37 38 |
# File 'lib/brute/hooks.rb', line 36 def initialize(*hooks) @hooks = hooks end |
Instance Method Details
#<<(hook) ⇒ Object
44 45 46 47 |
# File 'lib/brute/hooks.rb', line 44 def <<(hook) @hooks << hook self end |
#call(event, **data) ⇒ Object
40 41 42 |
# File 'lib/brute/hooks.rb', line 40 def call(event, **data) @hooks.each { |h| h.call(event, **data) } end |