Class: EventSourcing::Event::Stream

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/event_sourcing/event/stream.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, events, version, store) ⇒ Stream

Returns a new instance of Stream.



7
8
9
10
11
12
# File 'lib/event_sourcing/event/stream.rb', line 7

def initialize(id, events, version, store)
  @id       = id
  @events  = events
  @version = version
  @store   = store
end

Instance Attribute Details

#versionObject (readonly)

Returns the value of attribute version.



4
5
6
# File 'lib/event_sourcing/event/stream.rb', line 4

def version
  @version
end

Instance Method Details

#append(events) ⇒ Object



18
19
20
# File 'lib/event_sourcing/event/stream.rb', line 18

def append(events)
  @store.append(@id, @version, events)
end

#each(&block) ⇒ Object



14
15
16
# File 'lib/event_sourcing/event/stream.rb', line 14

def each(&block)
  @events.each(&block)
end