class SidekiqUniqueJobs::Deprecation

Class Deprecation provides logging of deprecations

@author Mikael Henriksson <mikael@mhenrixon.com>

Public Class Methods

muted() { || ... } click to toggle source

Mute warnings from this gem in a threaded context

@return [void] <description>

@yieldreturn [void]

# 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?() click to toggle source

Check if deprecation warnings have been muted

@return [true,false]

# File lib/sidekiq_unique_jobs/deprecation.rb, line 31
def self.muted?
  Thread.current[:uniquejobs_mute_deprecations] == true
end
warn(msg) click to toggle source

Warn about deprecation

@param [String] msg a descriptive reason for why the deprecation

@return [void]

# 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) click to toggle source

Warn about deprecation and provide a context

@param [String] msg a descriptive reason for why the deprecation

@return [void]

# 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