Sha256: 96fe9b3e58466c7477866743c1ded0e303bcfd519bf6e8c7316b85a30d73c91e

Contents?: true

Size: 1.85 KB

Versions: 21

Compression:

Stored size: 1.85 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)
          disallowed = ActiveSupport::Deprecation.disallowed_warnings
          return false if explicitly_allowed?(message)
          return true if disallowed == :all
          disallowed.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
          allowances = [allowances] unless allowances.kind_of?(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

21 entries across 20 versions & 6 rubygems

Version Path
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.3.0/gems/activesupport-7.0.8.7/lib/active_support/deprecation/disallowed.rb
activesupport-7.0.8.7 lib/active_support/deprecation/disallowed.rb
activesupport-7.0.8.6 lib/active_support/deprecation/disallowed.rb
activesupport-7.0.8.5 lib/active_support/deprecation/disallowed.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.8.4/lib/active_support/deprecation/disallowed.rb
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/activesupport-7.0.5.1/lib/active_support/deprecation/disallowed.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/activesupport-7.0.5.1/lib/active_support/deprecation/disallowed.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/activesupport-7.0.5.1/lib/active_support/deprecation/disallowed.rb
activesupport-7.0.8.4 lib/active_support/deprecation/disallowed.rb
activesupport-7.0.8.1 lib/active_support/deprecation/disallowed.rb
activesupport-7.0.8 lib/active_support/deprecation/disallowed.rb
activesupport-7.0.7.2 lib/active_support/deprecation/disallowed.rb
activesupport-7.0.7.1 lib/active_support/deprecation/disallowed.rb
activesupport-7.0.7 lib/active_support/deprecation/disallowed.rb
mlh-rubocop-config-1.0.2 vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.6/lib/active_support/deprecation/disallowed.rb
fablicop-1.10.3 vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.6/lib/active_support/deprecation/disallowed.rb
fablicop-1.10.3 vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.5/lib/active_support/deprecation/disallowed.rb
activesupport-7.0.6 lib/active_support/deprecation/disallowed.rb
activesupport-7.0.5.1 lib/active_support/deprecation/disallowed.rb
fablicop-1.10.2 vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.5/lib/active_support/deprecation/disallowed.rb