Class: Sequent::Util::DryRun::EventStoreProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/sequent/util/dry_run.rb

Overview

Proxies the given EventStore implements commit_events that instead of publish and store just publishes the events.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(result, event_store) ⇒ EventStoreProxy

Returns a new instance of EventStoreProxy.



43
44
45
46
47
# File 'lib/sequent/util/dry_run.rb', line 43

def initialize(result, event_store)
  @event_store = event_store
  @command_with_events = {}
  @result = result
end

Instance Attribute Details

#command_with_eventsObject (readonly)

Returns the value of attribute command_with_events.



35
36
37
# File 'lib/sequent/util/dry_run.rb', line 35

def command_with_events
  @command_with_events
end

#event_storeObject (readonly)

Returns the value of attribute event_store.



35
36
37
# File 'lib/sequent/util/dry_run.rb', line 35

def event_store
  @event_store
end

Instance Method Details

#commit_events(command, streams_with_events) ⇒ Object



49
50
51
52
53
54
# File 'lib/sequent/util/dry_run.rb', line 49

def commit_events(command, streams_with_events)
  Sequent.configuration.event_publisher.publish_events(streams_with_events.flat_map { |_, events| events })

  new_events = streams_with_events.flat_map { |_, events| events }
  @result.published_command_with_events(command, new_events)
end