Class: WithTransactionalLock::Mixin::AdvisoryLockBase

Inherits:
Object
  • Object
show all
Defined in:
lib/with_transactional_lock/mixin.rb

Direct Known Subclasses

PostgresAdvisoryLock

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(connection, lock_name) ⇒ AdvisoryLockBase

Returns a new instance of AdvisoryLockBase.



38
39
40
41
# File 'lib/with_transactional_lock/mixin.rb', line 38

def initialize(connection, lock_name)
  @connection = connection
  @lock_name = lock_name
end

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



36
37
38
# File 'lib/with_transactional_lock/mixin.rb', line 36

def connection
  @connection
end

#lock_nameObject (readonly)

Returns the value of attribute lock_name.



36
37
38
# File 'lib/with_transactional_lock/mixin.rb', line 36

def lock_name
  @lock_name
end

Instance Method Details

#yield_with_lockObject



43
44
45
46
47
48
# File 'lib/with_transactional_lock/mixin.rb', line 43

def yield_with_lock
  connection.transaction do
    acquire_lock
    yield
  end
end