Sha256: d0a542379a099c836e93c0875fc2b948343ea4c0c4722851d14bc3a27c875cef
Contents?: true
Size: 1.38 KB
Versions: 37
Compression:
Stored size: 1.38 KB
Contents
# frozen_string_literal: true module SidekiqUniqueJobs # # Class Deprecation provides logging of deprecations # # @author Mikael Henriksson <mikael@mhenrixon.com> # class Deprecation # # Mute warnings from this gem in a threaded context # # # @return [void] <description> # # @yieldreturn [void] 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 # # Check if deprecation warnings have been muted # # # @return [true,false] # def self.muted? Thread.current[:uniquejobs_mute_deprecations] == true end # # Warn about deprecation # # @param [String] msg a descriptive reason for why the deprecation # # @return [void] # def self.warn(msg) return if SidekiqUniqueJobs::Deprecation.muted? warn "DEPRECATION WARNING: #{msg}" nil end # # Warn about deprecation and provide a context # # @param [String] msg a descriptive reason for why the deprecation # # @return [void] # def self.warn_with_backtrace(msg) return if SidekiqUniqueJobs::Deprecation.muted? trace = "\n\nCALLED FROM:\n#{caller.join("\n")}" warn(msg + trace) nil end end end
Version data entries
37 entries across 37 versions & 1 rubygems