module JustOneLock

Constants

VERSION

Public Class Methods

prevent_multiple_executions( scope, locker = JustOneLock::NonBlockingLocker.new, &block ) click to toggle source
# File lib/just_one_lock.rb, line 20
def self.prevent_multiple_executions(
  scope,
  locker = JustOneLock::NonBlockingLocker.new,
  &block
)
  scope_name = scope.gsub(':', '_')
  lock_path = File.join(world.directory, scope_name + '.lock')

  begin
    return locker.lock(lock_path, &block)
  rescue JustOneLock::AlreadyLocked => e
    locker.already_locked(scope)
  end
end
world() click to toggle source
# File lib/just_one_lock.rb, line 16
def self.world
  @world ||= JustOneLock::World.new
end