Class: SidekiqUniqueJobs::Deprecation

Inherits:
Object
  • Object
show all
Defined in:
lib/sidekiq_unique_jobs/deprecation.rb

Overview

Class Deprecation provides logging of deprecations

Author:

Class Method Summary collapse

Class Method Details

.mutedvoid

This method returns an undefined value.

Mute warnings from this gem in a threaded context

Yield Returns:

  • (void)


17
18
19
20
21
22
23
# File 'lib/sidekiq_unique_jobs/deprecation.rb', line 17

def self.muted
  orig_val = Thread.current[:uniquejobs_mute_deprecations]
  Thread.current[:uniquejobs_mute_deprecations] = true
  yield
ensure
  Thread.current[:uniquejobs_mute_deprecations] = orig_val
end

.muted?true, false

Check if deprecation warnings have been muted

Returns:

  • (true, false)


31
32
33
# File 'lib/sidekiq_unique_jobs/deprecation.rb', line 31

def self.muted?
  Thread.current[:uniquejobs_mute_deprecations] == true
end

.warn(msg) ⇒ void

This method returns an undefined value.

Warn about deprecation

Parameters:

  • msg (String)

    a descriptive reason for why the deprecation



42
43
44
45
46
47
# File 'lib/sidekiq_unique_jobs/deprecation.rb', line 42

def self.warn(msg)
  return if SidekiqUniqueJobs::Deprecation.muted?

  warn "DEPRECATION WARNING: #{msg}"
  nil
end

.warn_with_backtrace(msg) ⇒ void

This method returns an undefined value.

Warn about deprecation and provide a context

Parameters:

  • msg (String)

    a descriptive reason for why the deprecation



56
57
58
59
60
61
62
63
# File 'lib/sidekiq_unique_jobs/deprecation.rb', line 56

def self.warn_with_backtrace(msg)
  return if SidekiqUniqueJobs::Deprecation.muted?

  trace = "\n\nCALLED FROM:\n#{caller.join("\n")}"
  warn(msg + trace)

  nil
end