Exception: Locksy::LockNotOwnedError

Inherits:
RuntimeError
  • Object
show all
Defined in:
lib/locksy/errors.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(msg = nil, lock:, current_owner: nil, current_expiry: nil) ⇒ LockNotOwnedError

Returns a new instance of LockNotOwnedError.



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/locksy/errors.rb', line 5

def initialize(msg = nil, lock:, current_owner: nil, current_expiry: nil)
  @lock = lock
  @current_owner = current_owner
  @current_expiry = current_expiry

  if msg.nil?
    msg = "Unable to manipulate lock #{lock.lock_name} for #{lock.owner}."
    msg += " Lock currently owned by #{current_owner}." if current_owner
    msg += " Lock unnavailable until #{current_expiry}." if current_expiry
  end

  super msg
end

Instance Attribute Details

#current_expiryObject (readonly)

Returns the value of attribute current_expiry.



3
4
5
# File 'lib/locksy/errors.rb', line 3

def current_expiry
  @current_expiry
end

#current_ownerObject (readonly)

Returns the value of attribute current_owner.



3
4
5
# File 'lib/locksy/errors.rb', line 3

def current_owner
  @current_owner
end

#lockObject (readonly)

Returns the value of attribute lock.



3
4
5
# File 'lib/locksy/errors.rb', line 3

def lock
  @lock
end