Class: TransactionalLock::TransactionWrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/transactional_lock/transaction_wrapper.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.deassign_root_wrapper(wrapper) ⇒ Object

If the specified wrapper is the root wrapper, it will be deassigned and the block passed to this function will be executed



12
13
14
15
16
17
# File 'lib/transactional_lock/transaction_wrapper.rb', line 12

def self.deassign_root_wrapper(wrapper)
  if wrapper == @root_wrapper
    @root_wrapper = nil
    yield
  end
end

.try_assign_root_wrapper(wrapper) ⇒ Object

If the root wrapper is not yet set, the specified wrapper will become the root wrapper.



6
7
8
# File 'lib/transactional_lock/transaction_wrapper.rb', line 6

def self.try_assign_root_wrapper(wrapper)
  @root_wrapper ||= wrapper
end

Instance Method Details

#wrapObject



19
20
21
22
23
24
25
26
# File 'lib/transactional_lock/transaction_wrapper.rb', line 19

def wrap
  self.class.try_assign_root_wrapper(self)
  yield
ensure
  self.class.deassign_root_wrapper(self) do
    ::TransactionalLock::AdvisoryLock.release_all_locks
  end
end