module GlobalLock::Lockable

Public Class Methods

included(other_mod) click to toggle source
# File lib/global_lock/lockable.rb, line 3
def self.included(other_mod)
  # This pattern lets us have instance _and_ class methods in this module
  other_mod.extend ClassMethods
end

Public Instance Methods

lock(opts={}) click to toggle source
# File lib/global_lock/lockable.rb, line 12
def lock(opts={})
GlobalLock.singleton.lock(lock_id, opts)
end
lock_id() click to toggle source
# File lib/global_lock/lockable.rb, line 8
def lock_id
  send(self.class.lock_id_name)
end
unlock(key) click to toggle source
# File lib/global_lock/lockable.rb, line 16
def unlock(key)
  GlobalLock.singleton.unlock(lock_id, key)
end
with_lock(existing_key=nil, opts={}, &block) click to toggle source
# File lib/global_lock/lockable.rb, line 20
def with_lock(existing_key=nil, opts={}, &block)
GlobalLock.singleton.with_lock(lock_id, existing_key, opts, &block)
end