Module: Mongo::Lock::ClassConvenienceMethods

Included in:
Mongo::Lock
Defined in:
lib/mongo-lock/class_convenience_methods.rb

Instance Method Summary collapse

Instance Method Details

#acquire(key, options = {}, &block) ⇒ Object



11
12
13
# File 'lib/mongo-lock/class_convenience_methods.rb', line 11

def acquire key, options = {}, &block
  init_and_send key, options, :acquire, &block
end

#acquire!(key, options = {}) ⇒ Object



19
20
21
# File 'lib/mongo-lock/class_convenience_methods.rb', line 19

def acquire! key, options = {}
  init_and_send key, options, :acquire!
end

#available?(key, options = {}) ⇒ Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/mongo-lock/class_convenience_methods.rb', line 27

def available? key, options = {}
  Mongo::Lock.new(key, options).available?
end

#init_and_send(key, options = {}, method, &block) ⇒ Object



5
6
7
8
9
# File 'lib/mongo-lock/class_convenience_methods.rb', line 5

def init_and_send key, options = {}, method, &block
  lock = Mongo::Lock.new(key, options)
  lock.send(method, &block)
  lock
end

#release(key, options = {}) ⇒ Object



15
16
17
# File 'lib/mongo-lock/class_convenience_methods.rb', line 15

def release key, options = {}
  init_and_send key, options, :release
end

#release!(key, options = {}) ⇒ Object



23
24
25
# File 'lib/mongo-lock/class_convenience_methods.rb', line 23

def release! key, options = {}
  init_and_send key, options, :release!
end