Class: Synapse::UnitOfWork::UnitOfWorkFactory

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

Overview

Factory that creates and configures new unit of work instances

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(provider) ⇒ undefined

Parameters:



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

def initialize(provider)
  @provider = provider
end

Instance Attribute Details

#transaction_managerTransactionManager

Returns:



6
7
8
# File 'lib/synapse/uow/factory.rb', line 6

def transaction_manager
  @transaction_manager
end

Instance Method Details

#createUnitOfWork

Creates and starts a unit of work

Returns:



16
17
18
19
20
21
22
23
24
25
# File 'lib/synapse/uow/factory.rb', line 16

def create
  unit = UnitOfWork.new @provider
  unit.tap do
    if @transaction_manager
      unit.transaction_manager = @transaction_manager
    end

    unit.start
  end
end