lib/mongoid/lock/synch_methods.rb in mongoid-lock-0.0.6 vs lib/mongoid/lock/synch_methods.rb in mongoid-lock-0.0.7

- old
+ new

@@ -6,19 +6,20 @@ def local_mutex @__mutex ||= Mutex.new end def reset_lock! - self.set(:lock_used_by, nil) + self.update_attributes(:lock_used_by => nil, :lock_acquired_at => nil) end def lock_acquire local = "#{Socket.gethostname}:#{Process.pid}" ident = self.lock_used_by if (ident and ident != local) raise Mongoid::Lock::UnsynchronizedAccess.new(ident) else self.set(:lock_used_by, local) + self.update_attributes(:lock_used_by => local, :lock_acquired_at => Time.now) end end def lock_release local = "#{Socket.gethostname}:#{Process.pid}" \ No newline at end of file