Class: RubyEventStore::ComposedDispatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_event_store/composed_dispatcher.rb

Instance Method Summary collapse

Constructor Details

#initialize(*dispatchers) ⇒ ComposedDispatcher

Returns a new instance of ComposedDispatcher.


5
6
7
# File 'lib/ruby_event_store/composed_dispatcher.rb', line 5

def initialize(*dispatchers)
  @dispatchers = dispatchers
end

Instance Method Details

#call(subscriber, event, record) ⇒ Object


9
10
11
12
13
14
15
16
# File 'lib/ruby_event_store/composed_dispatcher.rb', line 9

def call(subscriber, event, record)
  @dispatchers.each do |dispatcher|
    if dispatcher.verify(subscriber)
      dispatcher.call(subscriber, event, record)
      break
    end
  end
end

#verify(subscriber) ⇒ Object


18
19
20
21
22
# File 'lib/ruby_event_store/composed_dispatcher.rb', line 18

def verify(subscriber)
  @dispatchers.any? do |dispatcher|
    dispatcher.verify(subscriber)
  end
end