Sha256: 19bbbf2d14a895061644121027e5699592c741aa055f734234a7c5217414675e

Contents?: true

Size: 839 Bytes

Versions: 6

Compression:

Stored size: 839 Bytes

Contents

# frozen_string_literal: true

module SidekiqUniqueJobs
  #
  # Class Deprecation provides logging of deprecations
  #
  # @author Mikael Henriksson <mikael@mhenrixon.com>
  #
  class Deprecation
    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

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

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

      warn "DEPRECATION WARNING: #{msg}"
    end

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

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
sidekiq-unique-jobs-7.1.6 lib/sidekiq_unique_jobs/deprecation.rb
sidekiq-unique-jobs-7.1.5 lib/sidekiq_unique_jobs/deprecation.rb
sidekiq-unique-jobs-7.1.3 lib/sidekiq_unique_jobs/deprecation.rb
sidekiq-unique-jobs-7.1.2 lib/sidekiq_unique_jobs/deprecation.rb
sidekiq-unique-jobs-7.1.1 lib/sidekiq_unique_jobs/deprecation.rb
sidekiq-unique-jobs-7.1.0 lib/sidekiq_unique_jobs/deprecation.rb