Class: WithTransactionalLock::Mixin::AdvisoryLockBase
- Inherits:
-
Object
- Object
- WithTransactionalLock::Mixin::AdvisoryLockBase
- Defined in:
- lib/with_transactional_lock/mixin.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#lock_name ⇒ Object
readonly
Returns the value of attribute lock_name.
Instance Method Summary collapse
-
#initialize(connection, lock_name) ⇒ AdvisoryLockBase
constructor
A new instance of AdvisoryLockBase.
- #yield_with_lock ⇒ Object
Constructor Details
#initialize(connection, lock_name) ⇒ AdvisoryLockBase
Returns a new instance of AdvisoryLockBase.
37 38 39 40 |
# File 'lib/with_transactional_lock/mixin.rb', line 37 def initialize(connection, lock_name) @connection = connection @lock_name = lock_name end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
35 36 37 |
# File 'lib/with_transactional_lock/mixin.rb', line 35 def connection @connection end |
#lock_name ⇒ Object (readonly)
Returns the value of attribute lock_name.
35 36 37 |
# File 'lib/with_transactional_lock/mixin.rb', line 35 def lock_name @lock_name end |
Instance Method Details
#yield_with_lock ⇒ Object
42 43 44 45 46 47 |
# File 'lib/with_transactional_lock/mixin.rb', line 42 def yield_with_lock connection.transaction do acquire_lock yield end end |