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)


47
48
49
50
51
# File 'lib/synapse/domain/stream.rb', line 47

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)

Raises:

  • (NotImplementedError)


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

def end?
  raise NotImplementedError
end

#next_eventDomainEventMessage

This method is abstract.

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

Returns:

Raises:

  • (NotImplementedError)


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

def next_event
  raise NotImplementedError
end

#peekDomainEventMessage

This method is abstract.

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

Returns:

Raises:

  • (NotImplementedError)


39
40
41
# File 'lib/synapse/domain/stream.rb', line 39

def peek
  raise NotImplementedError
end

#to_aArray<DomainEventMessage>

Returns the domain events in this stream as an array

Returns:



55
56
57
58
59
60
61
62
# File 'lib/synapse/domain/stream.rb', line 55

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

  events
end