It's sometimes useful to allow some deprecations based on where they
get called from.
Imagine this kind of code:
def foo
1000.times do
deprecation_call
end
end
def bar
deprecation_call
end
private
def deprecation_call
ActiveSupport::Deprecation.warn('Something')
end
Calling foo, will trigger a thousand deprecations that you'll to
record. You currently can whitelist the Something deprecation,
but if you do that will also ignore the deprecation that gets
triggered when calling bar.
If you want to fine grain, which deprecations should be allowed
based on the caller, then this PR allows you that.
The Configuration.allowed_deprecations now accepts procs. Procs
will be passed the deprecation message as well as the stacktrace.
Your proc needs to return a truthy value if the deprecation is
allowed.
It's sometimes useful to allow some deprecations based on where they get called from.
Imagine this kind of code:
Calling
foo
, will trigger a thousand deprecations that you'll to record. You currently can whitelist theSomething
deprecation, but if you do that will also ignore the deprecation that gets triggered when callingbar
.If you want to fine grain, which deprecations should be allowed based on the caller, then this PR allows you that.
The
Configuration.allowed_deprecations
now accepts procs. Procs will be passed the deprecation message as well as the stacktrace. Your proc needs to return a truthy value if the deprecation is allowed.