Class: Synapse::Repository::Repository Abstract
- Inherits:
-
Object
- Object
- Synapse::Repository::Repository
- Defined in:
- lib/synapse/repository/repository.rb
Overview
Represents a mechanism for loading and storing aggregates
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#add(aggregate) ⇒ undefined
abstract
Adds a new, unmanaged aggregate to the repository.
-
#load(aggregate_id, expected_version = nil) ⇒ AggregateRoot
abstract
Loads an aggregate with the given aggregate identifier.
Instance Attribute Details
#event_bus ⇒ EventBus
7 8 9 |
# File 'lib/synapse/repository/repository.rb', line 7 def event_bus @event_bus end |
#unit_provider ⇒ UnitOfWorkProvider
10 11 12 |
# File 'lib/synapse/repository/repository.rb', line 10 def unit_provider @unit_provider end |
Instance Method Details
#add(aggregate) ⇒ undefined
Adds a new, unmanaged aggregate to the repository
This method will not force the repository to save the aggregate immediately. Instead, it is registered with the current unit of work. To force storage of an aggregate, commit the current unit of work.
43 44 45 |
# File 'lib/synapse/repository/repository.rb', line 43 def add(aggregate) raise NotImplementedError end |
#load(aggregate_id, expected_version = nil) ⇒ AggregateRoot
Loads an aggregate with the given aggregate identifier
If an expected version is specified and the aggregate’s actual version doesn’t equal the expected version, the implementation can choose to do one of the following:
-
Raise an exception immediately
-
Raise an exception at any other time while the aggregate is registered with the current unit of work.
29 30 31 |
# File 'lib/synapse/repository/repository.rb', line 29 def load(aggregate_id, expected_version = nil) raise NotImplementedError end |