Class: Aggregates::EventStream
- Inherits:
-
Object
- Object
- Aggregates::EventStream
- Defined in:
- lib/aggregates/event_stream.rb
Overview
An EventStream is a sequence, append only sequence of events that are read when reconstructing aggregates and written to when a command is processed by the aggregate.
There is likely no need to interact with this class directly.
Instance Method Summary collapse
-
#initialize(aggregate_id) ⇒ EventStream
constructor
A new instance of EventStream.
- #load_events ⇒ Object
- #publish(event) ⇒ Object
Constructor Details
#initialize(aggregate_id) ⇒ EventStream
Returns a new instance of EventStream.
9 10 11 12 |
# File 'lib/aggregates/event_stream.rb', line 9 def initialize(aggregate_id) @aggregate_id = aggregate_id @config = Configuration.instance end |
Instance Method Details
#load_events ⇒ Object
14 15 16 |
# File 'lib/aggregates/event_stream.rb', line 14 def load_events @config.storage_backend.load_events_by_aggregate_id(@aggregate_id) end |
#publish(event) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/aggregates/event_stream.rb', line 18 def publish(event) @config.event_processors.each do |event_processor| event_processor.process_event event end @config.storage_backend.store_event event end |