Class: Brute::Hooks::Composite

Inherits:
Base
  • Object
show all
Defined in:
lib/brute/hooks.rb

Overview

Composes multiple hooks into one, firing them in order.

Instance Method Summary collapse

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