Class: SidekiqUniqueJobs::Deprecation
- Inherits:
-
Object
- Object
- SidekiqUniqueJobs::Deprecation
- Defined in:
- lib/sidekiq_unique_jobs/deprecation.rb
Overview
Class Deprecation provides logging of deprecations
Class Method Summary collapse
-
.muted ⇒ void
Mute warnings from this gem in a threaded context.
-
.muted? ⇒ true, false
Check if deprecation warnings have been muted.
-
.warn(msg) ⇒ void
Warn about deprecation.
-
.warn_with_backtrace(msg) ⇒ void
Warn about deprecation and provide a context.
Class Method Details
.muted ⇒ void
This method returns an undefined value.
Mute warnings from this gem in a threaded context
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
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
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
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 |