Class: RubyEventStore::CorrelatedCommands
- Inherits:
-
Object
- Object
- RubyEventStore::CorrelatedCommands
- Defined in:
- lib/ruby_event_store/correlated_commands.rb
Defined Under Namespace
Classes: MiniEvent
Instance Method Summary collapse
- #call(command) ⇒ Object
-
#initialize(event_store, command_bus) ⇒ CorrelatedCommands
constructor
A new instance of CorrelatedCommands.
Constructor Details
#initialize(event_store, command_bus) ⇒ CorrelatedCommands
Returns a new instance of CorrelatedCommands.
5 6 7 8 |
# File 'lib/ruby_event_store/correlated_commands.rb', line 5 def initialize(event_store, command_bus) @event_store = event_store @command_bus = command_bus end |
Instance Method Details
#call(command) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/ruby_event_store/correlated_commands.rb', line 13 def call(command) correlation_id = event_store.[:correlation_id] causation_id = event_store.[:causation_id] if correlation_id && causation_id command.correlate_with(MiniEvent.new(correlation_id, causation_id)) if command.respond_to?(:correlate_with) event_store.(causation_id: command.) { command_bus.call(command) } else event_store.(correlation_id: command., causation_id: command.) do command_bus.call(command) end end end |