instance method
collect_deprecations
Ruby on Rails 7.1.6
Since v7.0.10Signature
collect_deprecations(deprecator = nil)
Returns the return value of the block and an array of all the deprecation warnings emitted by the given deprecator during the execution of the yielded block.
collect_deprecations(CustomDeprecator) do CustomDeprecator.warn "message" ActiveSupport::Deprecation.new.warn "other message" :result end # => [:result, ["message"]]
Parameters
-
deprecatoropt = nil
Source
# File activesupport/lib/active_support/testing/deprecation.rb, line 72
def collect_deprecations(deprecator = nil)
unless deprecator
ActiveSupport.deprecator.warn("collect_deprecations without a deprecator is deprecated")
deprecator = ActiveSupport::Deprecation._instance
end
old_behavior = deprecator.behavior
deprecations = []
deprecator.behavior = Proc.new do |message, callstack|
deprecations << message
end
result = yield
[result, deprecations]
ensure
deprecator.behavior = old_behavior
end
Defined in activesupport/lib/active_support/testing/deprecation.rb line 72
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveSupport::Testing::Deprecation