Module: Sidekiq Private

Defined in:
lib/sidekiq_unique_jobs/testing.rb,
lib/sidekiq_unique_jobs/sidekiq_unique_ext.rb

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Defined Under Namespace

Modules: Worker Classes: Job, JobRecord, JobSet, Queue, ScheduledSet, SortedEntry

Class Method Summary collapse

Class Method Details

.use_options(tmp_config = {}) ⇒ Object

Note:

this method will restore the original options after yielding

Temporarily turn Sidekiq’s options into something different

Parameters:

  • tmp_config (Hash<Symbol, Object>) (defaults to: {})

    the temporary config to use



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/sidekiq_unique_jobs/testing.rb', line 24

def self.use_options(tmp_config = {}) # rubocop:disable Metrics/MethodLength
  if respond_to?(:default_job_options)
    default_job_options.clear
    self.default_job_options = tmp_config
  else
    default_worker_options.clear
    self.default_worker_options = tmp_config
  end

  yield
ensure
  if respond_to?(:default_job_options)
    default_job_options.clear
    self.default_job_options = default_job_options
  else
    default_worker_options.clear
    self.default_worker_options = DEFAULT_WORKER_OPTIONS
  end
end