From 0b7067d8497c4d832b32233888ce973ab4357e5d Mon Sep 17 00:00:00 2001 From: Nikita Afanasenko Date: Mon, 29 Oct 2012 19:22:59 +0400 Subject: Provide a call stack for deprecation warnings where needed. It's sometimes hard to quickly find where deprecated call was performed, especially in case of migrating between Rails versions. So this is an attempt to improve the call stack part of the warning message by providing caller explicitly. --- activemodel/lib/active_model/attribute_methods.rb | 11 +++++------ activemodel/lib/active_model/observing.rb | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) (limited to 'activemodel/lib/active_model') diff --git a/activemodel/lib/active_model/attribute_methods.rb b/activemodel/lib/active_model/attribute_methods.rb index a1d01b2c89..0f5c7f13a8 100644 --- a/activemodel/lib/active_model/attribute_methods.rb +++ b/activemodel/lib/active_model/attribute_methods.rb @@ -383,12 +383,11 @@ module ActiveModel def initialize(options = {}) if options[:prefix] == '' || options[:suffix] == '' - ActiveSupport::Deprecation.warn( - "Specifying an empty prefix/suffix for an attribute method is no longer " \ - "necessary. If the un-prefixed/suffixed version of the method has not been " \ - "defined when `define_attribute_methods` is called, it will be defined " \ - "automatically." - ) + message = "Specifying an empty prefix/suffix for an attribute method is no longer " \ + "necessary. If the un-prefixed/suffixed version of the method has not been " \ + "defined when `define_attribute_methods` is called, it will be defined " \ + "automatically." + ActiveSupport::Deprecation.warn(message, caller) end @prefix, @suffix = options.fetch(:prefix, ''), options.fetch(:suffix, '') diff --git a/activemodel/lib/active_model/observing.rb b/activemodel/lib/active_model/observing.rb index 9419645e7b..277bf30b6a 100644 --- a/activemodel/lib/active_model/observing.rb +++ b/activemodel/lib/active_model/observing.rb @@ -172,7 +172,7 @@ module ActiveModel # count_observers is deprecated. Use #observers_count. def count_observers msg = "count_observers is deprecated in favor of observers_count" - ActiveSupport::Deprecation.warn(msg) + ActiveSupport::Deprecation.warn(msg, caller) observers_count end -- cgit v1.2.3