Class: LockManager
- Inherits:
-
Object
show all
- Defined in:
- lib/lock_manager.rb,
lib/lock_manager/worker.rb,
lib/lock_manager/connection.rb,
lib/lock_manager/redis_connection.rb
Defined Under Namespace
Classes: Connection, RedisConnection, Worker
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(options = {}) ⇒ LockManager
Returns a new instance of LockManager.
8
9
10
|
# File 'lib/lock_manager.rb', line 8
def initialize(options = {})
@options = options
end
|
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
6
7
8
|
# File 'lib/lock_manager.rb', line 6
def options
@options
end
|
Instance Method Details
#connection ⇒ Object
32
33
34
35
|
# File 'lib/lock_manager.rb', line 32
def connection
fail ArgumentError, ':type option is required' unless options[:type]
@connection ||= LockManager::Connection.connection_class(options[:type]).new(options)
end
|
#lock(host, user, reason = nil) ⇒ Object
12
13
14
|
# File 'lib/lock_manager.rb', line 12
def lock(host, user, reason = nil)
LockManager::Worker.new(connection, host).lock(user, reason)
end
|
#polling_lock(host, user, reason = nil) ⇒ Object
16
17
18
|
# File 'lib/lock_manager.rb', line 16
def polling_lock(host, user, reason = nil)
LockManager::Worker.new(connection, host).polling_lock(user, reason)
end
|
#unlock(host, user) ⇒ Object