Class: ActiveJob::Uniqueness::TestLockManager

Inherits:
Object
  • Object
show all
Defined in:
lib/active_job/uniqueness/test_lock_manager.rb

Overview

Mocks the full public API of ActiveJob::Uniqueness::LockManager so that enabling ActiveJob::Uniqueness.test_mode! never raises NoMethodError for a method the real manager (a Redlock::Client subclass) responds to.

Return values are consistent with "no lock is ever actually held": locking always succeeds, nothing is ever locked, and TTL lookups are nil.

See ActiveJob::Uniqueness.test_mode!

Instance Method Summary collapse

Instance Method Details

#delete_lock(*_args) ⇒ Object



44
45
46
# File 'lib/active_job/uniqueness/test_lock_manager.rb', line 44

def delete_lock(*_args)
  true
end

#delete_locks(*_args) ⇒ Object



48
49
50
# File 'lib/active_job/uniqueness/test_lock_manager.rb', line 48

def delete_locks(*_args)
  true
end

#get_remaining_ttl_for_lock(*_args) ⇒ Object



36
37
38
# File 'lib/active_job/uniqueness/test_lock_manager.rb', line 36

def get_remaining_ttl_for_lock(*_args)
  nil
end

#get_remaining_ttl_for_resource(*_args) ⇒ Object



40
41
42
# File 'lib/active_job/uniqueness/test_lock_manager.rb', line 40

def get_remaining_ttl_for_resource(*_args)
  nil
end

#lock(*_args) ⇒ Object



14
15
16
# File 'lib/active_job/uniqueness/test_lock_manager.rb', line 14

def lock(*_args)
  block_given? ? yield(true) : true
end

#lock!(*args, &block) ⇒ Object



18
19
20
21
22
# File 'lib/active_job/uniqueness/test_lock_manager.rb', line 18

def lock!(*args, &block)
  return lock(*args, &block) if block

  true
end

#locked?(*_args) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/active_job/uniqueness/test_lock_manager.rb', line 28

def locked?(*_args)
  false
end

#unlock(*_args) ⇒ Object



24
25
26
# File 'lib/active_job/uniqueness/test_lock_manager.rb', line 24

def unlock(*_args)
  nil
end

#valid_lock?(*_args) ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/active_job/uniqueness/test_lock_manager.rb', line 32

def valid_lock?(*_args)
  false
end