Class: RubyEventStore::ProcessManager::StateReplay
- Inherits:
-
Object
- Object
- RubyEventStore::ProcessManager::StateReplay
- Defined in:
- lib/ruby_event_store/process_manager/state_replay.rb
Defined Under Namespace
Instance Method Summary collapse
- #call(process_class, stream_name) ⇒ Object
-
#initialize(event_store:) ⇒ StateReplay
constructor
A new instance of StateReplay.
Constructor Details
#initialize(event_store:) ⇒ StateReplay
Returns a new instance of StateReplay.
9 10 11 |
# File 'lib/ruby_event_store/process_manager/state_replay.rb', line 9 def initialize(event_store:) @event_store = event_store end |
Instance Method Details
#call(process_class, stream_name) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/ruby_event_store/process_manager/state_replay.rb', line 13 def call(process_class, stream_name) process = process_class.new.with(event_store: @event_store, command_bus: nil) events = @event_store.read.stream(stream_name).to_a states = process.replay(events) Result.new( steps: events.zip(states).map { |event, state| Step.new(event: event, state: state) }, current_state: process.state, ) end |