Class: Synapse::EventSourcing::EventSourcingRepository

Inherits:
Repository::LockingRepository show all
Defined in:
lib/synapse/event_sourcing/repository.rb

Overview

Repository that initializes the state of aggregates using events read from an event store and appends changes to aggregates to an event store

Instance Attribute Summary collapse

Attributes inherited from Repository::LockingRepository

#lock_manager

Instance Method Summary collapse

Methods inherited from Repository::LockingRepository

#add, #load

Constructor Details

#initialize(aggregate_factory, event_store, lock_manager) ⇒ undefined

Parameters:



22
23
24
25
26
27
28
29
30
# File 'lib/synapse/event_sourcing/repository.rb', line 22

def initialize(aggregate_factory, event_store, lock_manager)
  super lock_manager

  @aggregate_factory = aggregate_factory
  @event_store = event_store
  @stream_decorators = Array.new
  @storage_listener =
    EventSourcedStorageListener.new @event_store, @lock_manager, @stream_decorators, type_identifier
end

Instance Attribute Details

#aggregate_factoryAggregateFactory (readonly)

Returns:



7
8
9
# File 'lib/synapse/event_sourcing/repository.rb', line 7

def aggregate_factory
  @aggregate_factory
end

#conflict_resolverConflictResolver

Returns:



10
11
12
# File 'lib/synapse/event_sourcing/repository.rb', line 10

def conflict_resolver
  @conflict_resolver
end

#event_storeEventStore (readonly)

Returns:



13
14
15
# File 'lib/synapse/event_sourcing/repository.rb', line 13

def event_store
  @event_store
end

#stream_decoratorsArray<EventStreamDecorator> (readonly)

Returns:



16
17
18
# File 'lib/synapse/event_sourcing/repository.rb', line 16

def stream_decorators
  @stream_decorators
end

Instance Method Details

#add_stream_decorator(stream_decorator) ⇒ undefined

Appends a stream decorator onto the end of the list of stream decorators

Parameters:

Returns:

  • (undefined)


36
37
38
# File 'lib/synapse/event_sourcing/repository.rb', line 36

def add_stream_decorator(stream_decorator)
  @stream_decorators.push stream_decorator
end