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.
35 36 37 38 |
# File 'lib/mongoid/locker.rb', line 35 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.
13 14 15 |
# File 'lib/mongoid/locker.rb', line 13 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.
28 29 30 |
# File 'lib/mongoid/locker.rb', line 28 def timeout_lock_after(new_time) @lock_timeout = new_time end |
#unlocked ⇒ Mongoid::Criteria
A scope to retrieve all unlocked documents in the collection.
20 21 22 |
# File 'lib/mongoid/locker.rb', line 20 def unlocked any_of({ locked_until: nil }, :locked_until.lte => Time.now) end |