Module: GraphMediator::Locking::InstanceMethods

Defined in:
lib/graph_mediator/locking.rb

Instance Method Summary collapse

Instance Method Details

#locking_enabled?Boolean

Overrides ActiveRecord::Locking::Optimistic#locking_enabled?

  • True if we are not in a mediated_transaction and lock_enabled? is true per ActiveRecord (lock_column exists and lock_optimistically? true)

  • True if we are in a mediated_transaction and lock_enabled? is true per ActiveRecord and we are in the midst of the version bumping phase of the transaction.

Effectively this ensures that an optimistic lock check and version bump occurs as usual outside of mediation but only at the end of the transaction within mediation.

Returns:

  • (Boolean)


43
44
45
46
47
# File 'lib/graph_mediator/locking.rb', line 43

def locking_enabled?
  locking_enabled = locking_enabled_without_mediation?
  locking_enabled &&= current_mediation_phase == :versioning if mediation_enabled? && currently_mediating?
  return locking_enabled
end