Class: Synapse::UnitOfWork::OuterCommitUnitOfWorkListener Private

Inherits:
UnitOfWorkListener show all
Defined in:
lib/synapse/uow/nesting.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

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

Instance Method Summary collapse

Methods inherited from UnitOfWorkListener

#on_event_registered, #on_prepare_commit, #on_prepare_transaction_commit, #on_start

Constructor Details

#initialize(inner_unit, provider) ⇒ undefined

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:



250
251
252
253
# File 'lib/synapse/uow/nesting.rb', line 250

def initialize(inner_unit, provider)
  @inner_unit = inner_unit
  @provider = provider
end

Instance Method Details

#after_commit(outer_unit) ⇒ undefined

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

Returns:

  • (undefined)


257
258
259
# File 'lib/synapse/uow/nesting.rb', line 257

def after_commit(outer_unit)
  @inner_unit.perform_inner_commit
end

#on_cleanup(outer_unit) ⇒ undefined

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

Returns:

  • (undefined)


276
277
278
# File 'lib/synapse/uow/nesting.rb', line 276

def on_cleanup(outer_unit)
  @inner_unit.perform_cleanup
end

#on_rollback(outer_unit, cause = nil) ⇒ undefined

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • outer_unit (UnitOfWork)
  • cause (Error) (defaults to: nil)

Returns:

  • (undefined)


264
265
266
267
268
269
270
271
272
# 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