Class: Euston::EventStore::Dispatcher::SynchronousDispatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/euston-eventstore/dispatcher/synchronous_dispatcher.rb

Instance Method Summary collapse

Constructor Details

#initialize(persistence, &block) ⇒ SynchronousDispatcher

Returns a new instance of SynchronousDispatcher.



5
6
7
8
# File 'lib/euston-eventstore/dispatcher/synchronous_dispatcher.rb', line 5

def initialize persistence, &block
  @persistence = persistence
  @dispatch = block
end

Instance Method Details

#dispatch(commit) ⇒ Object



10
11
12
13
# File 'lib/euston-eventstore/dispatcher/synchronous_dispatcher.rb', line 10

def dispatch commit
  @dispatch.call commit
  @persistence.mark_commit_as_dispatched commit
end

#lookupObject



15
16
17
# File 'lib/euston-eventstore/dispatcher/synchronous_dispatcher.rb', line 15

def lookup
  @persistence.get_undispatched_commits.each { |commit| dispatch commit }
end