aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/deprecation/reporting.rb
diff options
context:
space:
mode:
authorAlexey Gaziev <alex.gaziev@gmail.com>2012-10-30 10:23:41 +0800
committerAlexey Gaziev <alex.gaziev@gmail.com>2012-10-30 10:23:41 +0800
commitb955939d55b71905fa3e5036149ee4c84943c599 (patch)
treefaceebca94859de69e12f4d7b48e9958b1631575 /activesupport/lib/active_support/deprecation/reporting.rb
parent4e23c0ef341c2cba6a4b21022d4ffbabdaa6e3da (diff)
downloadrails-b955939d55b71905fa3e5036149ee4c84943c599.tar.gz
rails-b955939d55b71905fa3e5036149ee4c84943c599.tar.bz2
rails-b955939d55b71905fa3e5036149ee4c84943c599.zip
Make caller attribute in deprecation methods optional
Diffstat (limited to 'activesupport/lib/active_support/deprecation/reporting.rb')
-rw-r--r--activesupport/lib/active_support/deprecation/reporting.rb7
1 files changed, 5 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/deprecation/reporting.rb b/activesupport/lib/active_support/deprecation/reporting.rb
index 1ce54d9381..a7d265d732 100644
--- a/activesupport/lib/active_support/deprecation/reporting.rb
+++ b/activesupport/lib/active_support/deprecation/reporting.rb
@@ -11,8 +11,10 @@ module ActiveSupport
#
# ActiveSupport::Deprecation.warn('something broke!')
# # => "DEPRECATION WARNING: something broke! (called from your_code.rb:1)"
- def warn(message = nil, callstack = caller)
+ def warn(message = nil, callstack = nil)
return if silenced
+
+ callstack ||= caller(2)
deprecation_message(callstack, message).tap do |m|
behavior.each { |b| b.call(m, callstack) }
end
@@ -34,7 +36,8 @@ module ActiveSupport
@silenced = old_silenced
end
- def deprecation_warning(deprecated_method_name, message = nil, caller_backtrace = caller)
+ def deprecation_warning(deprecated_method_name, message = nil, caller_backtrace = nil)
+ caller_backtrace ||= caller(2)
deprecated_method_warning(deprecated_method_name, message).tap do |msg|
warn(msg, caller_backtrace)
end