Class: Synapse::EventStore::Mongo::CursorDomainEventStream

Inherits:
Domain::DomainEventStream
  • Object
show all
Defined in:
lib/synapse/event_store/mongo/cursor_event_stream.rb

Overview

TODO Document me

Instance Method Summary collapse

Constructor Details

#initialize(storage_strategy, cursor, last_snapshot_commit, aggregate_id) ⇒ undefined

Parameters:

  • storage_strategy (StorageStrategy)
  • cursor (Mongo::Cursor)
  • last_snapshot_commit (Array)
  • aggregate_id (Object)


11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/synapse/event_store/mongo/cursor_event_stream.rb', line 11

def initialize(storage_strategy, cursor, last_snapshot_commit, aggregate_id)
  @storage_strategy = storage_strategy
  @cursor = cursor
  @aggregate_id = aggregate_id

  if last_snapshot_commit
    # Current batch is an enumerator
    @current_batch = last_snapshot_commit.each
  else
    @current_batch = [].each
  end

  initialize_next_event
end

Instance Method Details

#end?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/synapse/event_store/mongo/cursor_event_stream.rb', line 27

def end?
  @next.nil?
end

#next_eventDomainEventMessage

Returns:

  • (DomainEventMessage)


32
33
34
35
36
# File 'lib/synapse/event_store/mongo/cursor_event_stream.rb', line 32

def next_event
  @next.tap do
    initialize_next_event
  end
end

#peekDomainEventMessage

Returns:

  • (DomainEventMessage)


39
40
41
# File 'lib/synapse/event_store/mongo/cursor_event_stream.rb', line 39

def peek
  @next
end