class EventStore::Aggregate
Attributes
checkpoint_events[R]
event_stream[R]
event_table[R]
id[R]
snapshot[R]
type[R]
Public Class Methods
count()
click to toggle source
# File lib/event_store/aggregate.rb, line 30 def self.count EventStore.db.from(EventStore.fully_qualified_table).select(:aggregate_id).distinct.count end
ids(offset, limit)
click to toggle source
# File lib/event_store/aggregate.rb, line 34 def self.ids(offset, limit) EventStore.db.from(EventStore.fully_qualified_table).select(:aggregate_id).distinct.order(:aggregate_id).limit(limit, offset).all.map{|item| item[:aggregate_id]} end
new(id, type = EventStore.table_name, checkpoint_events = [])
click to toggle source
# File lib/event_store/aggregate.rb, line 38 def initialize(id, type = EventStore.table_name, checkpoint_events = []) @id = id @type = type @checkpoint_events = checkpoint_events @snapshot = Snapshot.new(self) @event_stream = EventStream.new(self) end
Public Instance Methods
append(events, logger)
click to toggle source
# File lib/event_store/aggregate.rb, line 47 def append(events, logger) logger.debug("EventStore#append, appending to event stream") event_stream.append(events, logger) do |prepared_events| logger.debug("EventStore#append, storing snapshot") snapshot.store_snapshot(prepared_events, logger) end end
snapshot_exists?()
click to toggle source
# File lib/event_store/aggregate.rb, line 26 def snapshot_exists? @snapshot.exists? end