class Synapse::UnitOfWork::OuterCommitUnitOfWorkListener

Listener that allows a nested unit of work to properly operate within in a unit of work that is not aware of nesting

@api private

Public Class Methods

new(inner_unit, provider) click to toggle source

@param [UnitOfWork] inner_unit @param [UnitOfWorkProvider] provider @return [undefined]

# File lib/synapse/uow/nesting.rb, line 250
def initialize(inner_unit, provider)
  @inner_unit = inner_unit
  @provider = provider
end

Public Instance Methods

after_commit(outer_unit) click to toggle source

@param [UnitOfWork] outer_unit @return [undefined]

# File lib/synapse/uow/nesting.rb, line 257
def after_commit(outer_unit)
  @inner_unit.perform_inner_commit
end
on_cleanup(outer_unit) click to toggle source

@param [UnitOfWork] outer_unit @return [undefined]

# File lib/synapse/uow/nesting.rb, line 276
def on_cleanup(outer_unit)
  @inner_unit.perform_cleanup
end
on_rollback(outer_unit, cause = nil) click to toggle source

@param [UnitOfWork] outer_unit @param [Error] cause @return [undefined]

# File lib/synapse/uow/nesting.rb, line 264
def on_rollback(outer_unit, cause = nil)
  @provider.push @inner_unit

  begin
    @inner_unit.perform_rollback cause
  ensure
    @provider.clear @inner_unit
  end
end