Class: Royal::Locking::Pessimistic
- Inherits:
-
Object
- Object
- Royal::Locking::Pessimistic
- Defined in:
- lib/royal/locking/pessimistic.rb
Instance Method Summary collapse
Instance Method Details
#call(owner) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/royal/locking/pessimistic.rb', line 7 def call(owner) owner.transaction(requires_new: true) do # NOTE: Avoid using `lock!` to prevent reloading the record from DB. # We don't need any updated state, just exclusive use of the record. owner.class.where(id: owner).lock(true).take! yield end end |