Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct caller tracking in delegated deprecation methods #26686

Merged
merged 1 commit into from
Oct 4, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions activesupport/lib/active_support/deprecation/instance_delegator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class Deprecation
module InstanceDelegator # :nodoc:
def self.included(base)
base.extend(ClassMethods)
base.singleton_class.prepend(OverrideDelegators)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am curious to understand why you needed to add an extra module instead of just updating the caller_location calls like in #27254

base.public_class_method :new
end

Expand All @@ -19,6 +20,18 @@ def method_added(method_name)
singleton_class.delegate(method_name, to: :instance)
end
end

module OverrideDelegators # :nodoc:
def warn(message = nil, callstack = nil)
callstack ||= caller_locations(2)
super
end

def deprecation_warning(deprecated_method_name, message = nil, caller_backtrace = nil)
caller_backtrace ||= caller_locations(2)
super
end
end
end
end
end