Module: Mongoid::Locker::ClassMethods
- Defined in:
- lib/mongoid/locker.rb
Instance Method Summary collapse
-
#lock_timeout ⇒ Fixnum
Retrieve the lock timeout default for this class.
-
#locked ⇒ Mongoid::Criteria
A scope to retrieve all locked documents in the collection.
-
#timeout_lock_after(new_time) ⇒ void
Set the default lock timeout for this class.
-
#unlocked ⇒ Mongoid::Criteria
A scope to retrieve all unlocked documents in the collection.
Instance Method Details
#lock_timeout ⇒ Fixnum
Retrieve the lock timeout default for this class.
34 35 36 37 |
# File 'lib/mongoid/locker.rb', line 34 def lock_timeout # default timeout of five seconds @lock_timeout || 5 end |
#locked ⇒ Mongoid::Criteria
A scope to retrieve all locked documents in the collection.
12 13 14 |
# File 'lib/mongoid/locker.rb', line 12 def locked where :locked_until.gt => Time.now end |
#timeout_lock_after(new_time) ⇒ void
This method returns an undefined value.
Set the default lock timeout for this class. Note this only applies to new locks. Defaults to five seconds.
27 28 29 |
# File 'lib/mongoid/locker.rb', line 27 def timeout_lock_after(new_time) @lock_timeout = new_time end |
#unlocked ⇒ Mongoid::Criteria
A scope to retrieve all unlocked documents in the collection.
19 20 21 |
# File 'lib/mongoid/locker.rb', line 19 def unlocked any_of({ locked_until: nil }, { :locked_until.lte => Time.now }) end |