class Locksy::LockInterface

AbstractLock allows us to declare the interface for locks. Any locks created should follow this interface

disabling this cop because we are declaring this as an interface and deliberately not using here rubocop:disable Lint/UnusedMethodArgument

Attributes

default_expiry[R]
default_extension[R]
generate_default_lock_name[R]
generate_default_owner[R]
lock_name[R]
logger[RW]
owner[R]

Public Class Methods

new(lock_name: generate_default_lock_name, owner: generate_default_owner, default_expiry: nil, default_extension: nil, logger: nil, **_args) click to toggle source
# File lib/locksy/lock_interface.rb, line 11
def initialize(lock_name: generate_default_lock_name, owner: generate_default_owner,
  default_expiry: nil, default_extension: nil, logger: nil, **_args)
  raise NotImplementedError.new 'This is an abstract class - instantiation is not supported'
end

Public Instance Methods

obtain_lock(expire_after: default_expiry, **_args) click to toggle source

should return a boolean denoting lock obtained (true) or not (false)

# File lib/locksy/lock_interface.rb, line 17
def obtain_lock(expire_after: default_expiry, **_args)
  raise NotImplementedError.new 'Obtaining a lock is not supported'
end
refresh_lock(expire_after: default_extension, **_args) click to toggle source

should raise a LockNotOwnedError if the lock is not owned by the requested owner

# File lib/locksy/lock_interface.rb, line 22
def refresh_lock(expire_after: default_extension, **_args)
  raise NotImplementedError.new 'Refreshing a lock is not supported'
end
release_lock(**_args) click to toggle source

should raise a LockNotOwnedError if the lock is not owned by the requested owner

# File lib/locksy/lock_interface.rb, line 27
def release_lock(**_args)
  raise NotImplementedError.new 'Releasing a lock is not supported'
end
with_lock(expire_after: default_expiry, **_args) click to toggle source

should raise a LockNotOwnedError if the lock is not owned by the requested owner

# File lib/locksy/lock_interface.rb, line 32
def with_lock(expire_after: default_expiry, **_args)
  raise NotImplementedError.new 'Working with a lock is not supported'
end