Module: CurlyMustache::Locking::InstanceMethods
- Defined in:
- lib/curly_mustache/locking.rb
Instance Method Summary collapse
Instance Method Details
#lock(timeout = nil, &block) ⇒ Object
64 65 66 67 68 69 70 71 |
# File 'lib/curly_mustache/locking.rb', line 64 def lock(timeout = nil, &block) self.class.lock(self.id, timeout) or return false if block_given? self.class.do_locked_block(self.id, self.reload, &block) else true end end |
#locked? ⇒ Boolean
77 78 79 |
# File 'lib/curly_mustache/locking.rb', line 77 def locked? connection.locked?(self.class.lock_key(id)) end |
#unlock ⇒ Object
73 74 75 |
# File 'lib/curly_mustache/locking.rb', line 73 def unlock self.class.unlock(self.id) end |