Class: LockManager

Inherits:
Object
  • 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

#optionsObject (readonly)

Returns the value of attribute options.



6
7
8
# File 'lib/lock_manager.rb', line 6

def options
  @options
end

Instance Method Details

#connectionObject



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

#locked?(host) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/lock_manager.rb', line 24

def locked?(host)
  LockManager::Worker.new(connection, host).locked?
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

#show(host) ⇒ Object



28
29
30
# File 'lib/lock_manager.rb', line 28

def show(host)
  LockManager::Worker.new(connection, host).show
end

#unlock(host, user) ⇒ Object



20
21
22
# File 'lib/lock_manager.rb', line 20

def unlock(host, user)
  LockManager::Worker.new(connection, host).unlock(user)
end