lib/mongoid/locker.rb in mongoid-locker-0.1.0 vs lib/mongoid/locker.rb in mongoid-locker-0.1.1

- old
+ new

@@ -25,30 +25,28 @@ # Retrieve the lock timeout default for this class. # # @return [Fixnum] the default number of seconds until a lock is considered "expired", in seconds def lock_timeout - @lock_timeout + # default timeout of five seconds + @lock_timeout || 5 end end # @api private def self.included mod mod.extend ClassMethods mod.field :locked_at, :type => Time mod.field :locked_until, :type => Time - - # default timeout of five seconds - mod.instance_variable_set :@lock_timeout, 5 end # Returns whether the document is currently locked or not. # # @return [Boolean] true if locked, false otherwise def locked? - self.locked_until && self.locked_until > Time.now + !!(self.locked_until && self.locked_until > Time.now) end # Primary method of plugin: execute the provided code once the document has been successfully locked. # # @param [Hash] opts for the locking mechanism