Class: Synapse::Domain::DomainEventStream Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/synapse/domain/stream.rb

Overview

This class is abstract.

Represents a historical stream of domain events in chronological order

Examples:

stream = InMemoryDomainEventStream.new events
until stream.end?
  puts stream.next_event
end
stream = InMemoryDomainEventStream.new events
stream.each do |event|
  puts event
end

Instance Method Summary collapse

Instance Method Details

#each {|DomainEventMessage| ... } ⇒ undefined

Yields the next domain events in the stream until the end of the stream has been reached

Yields:

Returns:

  • (undefined)


43
44
45
46
47
# File 'lib/synapse/domain/stream.rb', line 43

def each
  until end?
    yield next_event
  end
end

#end?Boolean

This method is abstract.

Returns true if the end of the stream has been reached

Returns:

  • (Boolean)


23
24
25
# File 'lib/synapse/domain/stream.rb', line 23

def end?
  true
end

#next_eventDomainEventMessage

This method is abstract.

Returns the next event in the stream and moves the stream’s pointer forward

Returns:



31
# File 'lib/synapse/domain/stream.rb', line 31

def next_event; end

#peekDomainEventMessage

This method is abstract.

Returns the next event in the stream without moving the stream’s pointer forward

Returns:



37
# File 'lib/synapse/domain/stream.rb', line 37

def peek; end

#to_aArray<DomainEventMessage>

Returns the domain events in this stream as an array

Returns:



51
52
53
54
55
56
57
58
# File 'lib/synapse/domain/stream.rb', line 51

def to_a
  events = Array.new
  each do |event|
    events.push event
  end

  events
end