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.
39 40 41 42 |
# File 'lib/with_transactional_lock/mixin.rb', line 39 def initialize(connection, lock_name) @connection = connection @lock_name = lock_name end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
37 38 39 |
# File 'lib/with_transactional_lock/mixin.rb', line 37 def connection @connection end |
#lock_name ⇒ Object (readonly)
Returns the value of attribute lock_name.
37 38 39 |
# File 'lib/with_transactional_lock/mixin.rb', line 37 def lock_name @lock_name end |
Instance Method Details
#yield_with_lock ⇒ Object
44 45 46 47 48 49 |
# File 'lib/with_transactional_lock/mixin.rb', line 44 def yield_with_lock connection.transaction do acquire_lock yield end end |