Class: Restruct::Locker
Constant Summary
collapse
- REGISTER_LUA =
File.read "#{File.dirname(__FILE__)}/../../lua/register.lua"
- UNREGISTER_LUA =
File.read "#{File.dirname(__FILE__)}/../../lua/unregister.lua"
Instance Attribute Summary
Attributes inherited from Structure
#connection, #id
Instance Method Summary
collapse
Methods inherited from Structure
#==, #destroy, #dump, #exists?, #initialize, #restore
Instance Method Details
#key ⇒ Object
Also known as:
locked_by
19
20
21
|
# File 'lib/restruct/locker.rb', line 19
def key
connection.call('HGET', id, 'key')
end
|
#lock(key, &block) ⇒ Object
7
8
9
|
# File 'lib/restruct/locker.rb', line 7
def lock(key, &block)
_lock key, false, &block
end
|
#lock!(key, &block) ⇒ Object
11
12
13
|
# File 'lib/restruct/locker.rb', line 11
def lock!(key, &block)
_lock key, true, &block
end
|
#to_h ⇒ Object
Also known as:
to_primitive
24
25
26
|
# File 'lib/restruct/locker.rb', line 24
def to_h
::Hash[connection.call('HGETALL', id).each_slice(2).to_a]
end
|