Class: Synapse::EventStore::Mongo::DocumentPerEventStrategy
- Inherits:
-
StorageStrategy
- Object
- StorageStrategy
- Synapse::EventStore::Mongo::DocumentPerEventStrategy
- Defined in:
- lib/synapse/event_store/mongo/per_event_strategy.rb
Overview
Storage strategy that stores each event as its own document
Defined Under Namespace
Classes: EventDocument
Constant Summary
Constants inherited from StorageStrategy
StorageStrategy::ASCENDING, StorageStrategy::DESCENDING
Instance Method Summary collapse
Methods inherited from StorageStrategy
#ensure_indexes, #fetch_events, #fetch_last_snapshot, #initialize
Constructor Details
This class inherits a constructor from Synapse::EventStore::Mongo::StorageStrategy
Instance Method Details
#create_documents(type_identifier, events) ⇒ Array
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/synapse/event_store/mongo/per_event_strategy.rb', line 9 def create_documents(type_identifier, events) documents = Array.new events.each do |event| document = EventDocument.new document.from_event event, type_identifier, @serializer documents.push document.to_hash end documents end |
#extract_events(hash, aggregate_id) ⇒ Array
25 26 27 28 |
# File 'lib/synapse/event_store/mongo/per_event_strategy.rb', line 25 def extract_events(hash, aggregate_id) document = EventDocument.new document.from_hash(hash).to_events(aggregate_id, @serializer, @upcaster_chain) end |