module ActiveSupport::Deprecation::Reporting

def allow(allowed_warnings = :all, if: true, &block)

# => ActiveSupport::DeprecationException for dev/test, nil for production
end
ActiveSupport::Deprecation.warn('something broke!')
ActiveSupport::Deprecation.allow ['something broke'], if: Rails.env.production? do

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

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

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

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

+ActiveSupport::Deprecation.disallowed_warnings+
Matching warnings will be exempt from the rules set by
the text of deprecation warning messages generated within the block.
expressions. (Symbols are treated as strings). These are compared against
allowed_warnings can be an array containing strings, symbols, or regular
Allow previously disallowed deprecation warnings within the block.
def allow(allowed_warnings = :all, if: true, &block)
  conditional = binding.local_variable_get(:if)
  conditional = conditional.call if conditional.respond_to?(:call)
  if conditional
    @explicitly_allowed_warnings.bind(allowed_warnings, &block)
  else
    yield
  end
end