Class: Akasha::Storage::MemoryEventStore
- Inherits:
-
Object
- Object
- Akasha::Storage::MemoryEventStore
- Defined in:
- lib/akasha/storage/memory_event_store.rb,
lib/akasha/storage/memory_event_store/stream.rb
Overview
Memory-based event store.
Defined Under Namespace
Classes: Stream
Instance Attribute Summary collapse
-
#streams ⇒ Object
readonly
Access to streams Example: store.streams.
Instance Method Summary collapse
-
#initialize ⇒ MemoryEventStore
constructor
A new instance of MemoryEventStore.
-
#merge_all_by_event(into:, only:) ⇒ Object
Merges all streams into one, filtering the resulting stream so it only contains events with the specified names.
Constructor Details
#initialize ⇒ MemoryEventStore
Returns a new instance of MemoryEventStore.
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/akasha/storage/memory_event_store.rb', line 12 def initialize store = self @streams = Hash.new do |streams, name| streams[name] = Stream.new do |new_events| store.update_projections(new_events) new_events end end @projections = [] end |
Instance Attribute Details
#streams ⇒ Object (readonly)
Access to streams Example:
store.streams['some-stream-name']
10 11 12 |
# File 'lib/akasha/storage/memory_event_store.rb', line 10 def streams @streams end |
Instance Method Details
#merge_all_by_event(into:, only:) ⇒ Object
Merges all streams into one, filtering the resulting stream so it only contains events with the specified names.
Arguments:
`new_stream_name` - name of the new stream
`only` - array of event names
29 30 31 32 33 34 35 36 |
# File 'lib/akasha/storage/memory_event_store.rb', line 29 def merge_all_by_event(into:, only:) new_stream = Stream.new do |new_events| new_events.select { |event| only.include?(event.name) } end @streams[into] = new_stream @projections << new_stream new_stream end |