Sha256: 26466d75bc08ae901fc139cb5d3bdfa10b2daecd30c659174b1ad782e8d68d4c

Contents?: true

Size: 1.76 KB

Versions: 45

Compression:

Stored size: 1.76 KB

Contents

# frozen_string_literal: true

module ActiveSupport
  class Deprecation
    module Disallowed
      # Sets the criteria used to identify deprecation messages which should be
      # disallowed. Can be an array containing strings, symbols, or regular
      # expressions. (Symbols are treated as strings.) These are compared against
      # the text of the generated deprecation warning.
      #
      # Additionally the scalar symbol +:all+ may be used to treat all
      # deprecations as disallowed.
      #
      # Deprecations matching a substring or regular expression will be handled
      # using the configured Behavior#disallowed_behavior rather than
      # Behavior#behavior.
      attr_writer :disallowed_warnings

      # Returns the configured criteria used to identify deprecation messages
      # which should be treated as disallowed.
      def disallowed_warnings
        @disallowed_warnings ||= []
      end

      private
        def deprecation_disallowed?(message)
          return false if explicitly_allowed?(message)
          return true if disallowed_warnings == :all
          message && disallowed_warnings.any? do |rule|
            case rule
            when String, Symbol
              message.include?(rule.to_s)
            when Regexp
              rule.match?(message)
            end
          end
        end

        def explicitly_allowed?(message)
          allowances = @explicitly_allowed_warnings.value
          return false unless allowances
          return true if allowances == :all
          message && Array(allowances).any? do |rule|
            case rule
            when String, Symbol
              message.include?(rule.to_s)
            when Regexp
              rule.match?(message)
            end
          end
        end
    end
  end
end

Version data entries

45 entries across 45 versions & 8 rubygems

Version Path
activesupport-8.0.2 lib/active_support/deprecation/disallowed.rb
tailscale_middleware-0.0.3 vendor/cache/ruby/3.4.0/gems/activesupport-8.0.1/lib/active_support/deprecation/disallowed.rb
minato_ruby_api_client-0.2.2 vendor/bundle/ruby/3.2.0/gems/activesupport-7.1.3.4/lib/active_support/deprecation/disallowed.rb
activesupport-8.0.1 lib/active_support/deprecation/disallowed.rb
activesupport-8.0.0.1 lib/active_support/deprecation/disallowed.rb
activesupport-7.2.2.1 lib/active_support/deprecation/disallowed.rb
activesupport-7.1.5.1 lib/active_support/deprecation/disallowed.rb
activesupport-8.0.0 lib/active_support/deprecation/disallowed.rb
activesupport-7.2.2 lib/active_support/deprecation/disallowed.rb
activesupport-7.1.5 lib/active_support/deprecation/disallowed.rb
activesupport-8.0.0.rc2 lib/active_support/deprecation/disallowed.rb
activesupport-7.2.1.2 lib/active_support/deprecation/disallowed.rb
activesupport-7.1.4.2 lib/active_support/deprecation/disallowed.rb
activesupport-8.0.0.rc1 lib/active_support/deprecation/disallowed.rb
activesupport-7.2.1.1 lib/active_support/deprecation/disallowed.rb
activesupport-7.1.4.1 lib/active_support/deprecation/disallowed.rb
activesupport-8.0.0.beta1 lib/active_support/deprecation/disallowed.rb
omg-activesupport-8.0.0.alpha9 lib/active_support/deprecation/disallowed.rb
omg-activesupport-8.0.0.alpha8 lib/active_support/deprecation/disallowed.rb
omg-activesupport-8.0.0.alpha7 lib/active_support/deprecation/disallowed.rb