Class: Synapse::Repository::Repository Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/synapse/repository/repository.rb

Overview

This class is abstract.

Represents a mechanism for loading and storing aggregates

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#event_busEventBus

Returns:



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

def event_bus
  @event_bus
end

#unit_providerUnitOfWorkProvider

Returns:

  • (UnitOfWorkProvider)


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

def unit_provider
  @unit_provider
end

Instance Method Details

#add(aggregate) ⇒ undefined

This method is abstract.

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.

Parameters:

  • aggregate (AggregateRoot)

Returns:

  • (undefined)

Raises:

  • (ArgumentError)

    If the version of the aggregate is not null



43
44
45
# File 'lib/synapse/repository/repository.rb', line 43

def add(aggregate)
  raise NotImplementedError
end

#load(aggregate_id, expected_version = nil) ⇒ AggregateRoot

This method is abstract.

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.

Parameters:

  • aggregate_id (Object)
  • expected_version (Integer) (defaults to: nil)

    If this is nil, no version validation is performed

Returns:

  • (AggregateRoot)

Raises:



29
30
31
# File 'lib/synapse/repository/repository.rb', line 29

def load(aggregate_id, expected_version = nil)
  raise NotImplementedError
end