method

allow

Importance_2
v7.1.3.2 - Show latest stable - 0 notes - Class: Reporting
allow(allowed_warnings = :all, if: true, &block) public

Allow previously disallowed deprecation warnings within the block. allowed_warnings can be an array containing strings, symbols, or regular expressions. (Symbols are treated as strings). These are compared against the text of deprecation warning messages generated within the block. Matching warnings will be exempt from the rules set by ActiveSupport::Deprecation#disallowed_warnings.

The optional if: argument accepts a truthy/falsy value or an object that responds to .call. If truthy, then matching warnings will be allowed. If falsey then the method yields to the block without allowing the warning.

deprecator = ActiveSupport::Deprecation.new
deprecator.disallowed_behavior = :raise
deprecator.disallowed_warnings = [
  "something broke"
]

deprecator.warn('something broke!')
# => ActiveSupport::DeprecationException

deprecator.allow ['something broke'] do
  deprecator.warn('something broke!')
end
# => nil

deprecator.allow ['something broke'], if: Rails.env.production? do
  deprecator.warn('something broke!')
end
# => ActiveSupport::DeprecationException for dev/test, nil for production
Show source
Register or log in to add new notes.