module PgAdvisoryLocker
Constants
- VERSION
the current version of this gem
Public Class Methods
included(base)
click to toggle source
# File lib/pg_advisory_locker/pg_advisory_locker.rb, line 2 def self.included(base) base.extend(ClassMethods) end
Public Instance Methods
advisory_lock(&block)
click to toggle source
advisory lock this row associated identified by model#id
blocks until advisory lock is release acquires lock on return
if block is passed in, lock/unlock around the block
# File lib/pg_advisory_locker/pg_advisory_locker.rb, line 12 def advisory_lock(&block) return self.class.lock_record(id, &block) end
advisory_try_lock(&block)
click to toggle source
advisory try lock this row associated identified by model#id
if lock is acquired, acquires lock and returns true if lock is currently acquired, returns false never blocks
if block is passed in, lock/unlock around the block executing block only if lock is acquired
# File lib/pg_advisory_locker/pg_advisory_locker.rb, line 24 def advisory_try_lock(&block) return self.class.try_lock_record(id, &block) end
advisory_unlock()
click to toggle source
advisory unlock this row associated identified by model#id
on return releases lock
# File lib/pg_advisory_locker/pg_advisory_locker.rb, line 31 def advisory_unlock self.class.unlock_record(id) end