Permalink
Browse files

Make caller attribute in deprecation methods optional

  • Loading branch information...
1 parent 4e23c0e commit b955939d55b71905fa3e5036149ee4c84943c599 @gazay gazay committed Oct 30, 2012
Showing with 59 additions and 56 deletions.
  1. +2 −2 actionpack/lib/action_controller/record_identifier.rb
  2. +2 −2 actionpack/lib/action_dispatch/http/mime_type.rb
  3. +1 −2 actionpack/lib/action_dispatch/testing/integration.rb
  4. +1 −1 actionpack/lib/action_view/helpers/asset_tag_helper.rb
  5. +1 −1 actionpack/lib/action_view/helpers/date_helper.rb
  6. +1 −2 actionpack/lib/action_view/helpers/form_helper.rb
  7. +1 −1 actionpack/lib/action_view/helpers/form_options_helper.rb
  8. +5 −5 actionpack/lib/action_view/helpers/form_tag_helper.rb
  9. +2 −2 actionpack/lib/action_view/helpers/javascript_helper.rb
  10. +2 −2 actionpack/lib/action_view/helpers/url_helper.rb
  11. +1 −1 actionpack/lib/action_view/template.rb
  12. +1 −1 actionpack/lib/action_view/template/resolver.rb
  13. +1 −1 activemodel/lib/active_model/attribute_methods.rb
  14. +1 −1 activemodel/lib/active_model/observing.rb
  15. +1 −1 activerecord/lib/active_record/associations/association.rb
  16. +1 −1 activerecord/lib/active_record/attribute_methods/serialization.rb
  17. +4 −4 activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
  18. +1 −1 activerecord/lib/active_record/connection_adapters/column.rb
  19. +1 −1 activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb
  20. +1 −1 activerecord/lib/active_record/migration.rb
  21. +1 −1 activerecord/lib/active_record/readonly_attributes.rb
  22. +1 −2 activerecord/lib/active_record/scoping/default.rb
  23. +1 −2 activerecord/lib/active_record/scoping/named.rb
  24. +5 −0 activesupport/CHANGELOG.md
  25. +1 −1 activesupport/lib/active_support/benchmarkable.rb
  26. +2 −2 activesupport/lib/active_support/callbacks.rb
  27. +2 −2 activesupport/lib/active_support/core_ext/array/uniq_by.rb
  28. +1 −1 activesupport/lib/active_support/core_ext/date_time/calculations.rb
  29. +1 −1 activesupport/lib/active_support/core_ext/module/introspection.rb
  30. +1 −1 activesupport/lib/active_support/core_ext/proc.rb
  31. +1 −1 activesupport/lib/active_support/core_ext/string/encoding.rb
  32. +1 −1 activesupport/lib/active_support/deprecation/method_wrappers.rb
  33. +5 −2 activesupport/lib/active_support/deprecation/reporting.rb
  34. +1 −1 activesupport/lib/active_support/json/variable.rb
  35. +1 −1 activesupport/lib/active_support/test_case.rb
  36. +1 −1 activesupport/test/deprecation_test.rb
  37. +2 −3 railties/lib/rails/application/configuration.rb
@@ -8,12 +8,12 @@ module RecordIdentifier
'ActionView::RecodIdentifier module.'
def dom_id(record, prefix = nil)
- ActiveSupport::Deprecation.warn('dom_id ' + MESSAGE, caller)
+ ActiveSupport::Deprecation.warn('dom_id ' + MESSAGE)
ActionView::RecordIdentifier.dom_id(record, prefix)
end
def dom_class(record, prefix = nil)
- ActiveSupport::Deprecation.warn('dom_class ' + MESSAGE, caller)
+ ActiveSupport::Deprecation.warn('dom_class ' + MESSAGE)
ActionView::RecordIdentifier.dom_class(record, prefix)
end
end
@@ -275,12 +275,12 @@ def =~(mime_type)
# Returns true if Action Pack should check requests using this Mime Type for possible request forgery. See
# ActionController::RequestForgeryProtection.
def verify_request?
- ActiveSupport::Deprecation.warn("Mime::Type#verify_request? is deprecated and will be removed in Rails 4.1", caller)
+ ActiveSupport::Deprecation.warn "Mime::Type#verify_request? is deprecated and will be removed in Rails 4.1"
@@browser_generated_types.include?(to_sym)
end
def self.browser_generated_types
- ActiveSupport::Deprecation.warn("Mime::Type.browser_generated_types is deprecated and will be removed in Rails 4.1", caller)
+ ActiveSupport::Deprecation.warn "Mime::Type.browser_generated_types is deprecated and will be removed in Rails 4.1"
@@browser_generated_types
end
@@ -498,8 +498,7 @@ class IntegrationTest < ActiveSupport::TestCase
def self.app
if !@@app && !ActionDispatch.test_app
- ActiveSupport::Deprecation.warn "Rails application fallback is deprecated " \
- "and no longer works, please set ActionDispatch.test_app", caller
+ ActiveSupport::Deprecation.warn "Rails application fallback is deprecated and no longer works, please set ActionDispatch.test_app"
end
@@app || ActionDispatch.test_app
@@ -125,7 +125,7 @@ def auto_discovery_link_tag(type = :rss, url_options = {}, tag_options = {})
"the :type option key. This behavior is deprecated and will be remove in Rails 4.1. You should pass " +
":type option explicitly if you want to use other types, for example: " +
"auto_discovery_link_tag(:xml, '/feed.xml', :type => 'application/xml')"
- ActiveSupport::Deprecation.warn(message, caller)
+ ActiveSupport::Deprecation.warn message
end
tag(
@@ -69,7 +69,7 @@ def distance_of_time_in_words(from_time, to_time = 0, include_seconds_or_options
options = include_seconds_or_options
else
ActiveSupport::Deprecation.warn "distance_of_time_in_words and time_ago_in_words now accept :include_seconds " +
- "as a part of options hash, not a boolean argument", caller
+ "as a part of options hash, not a boolean argument"
options[:include_seconds] ||= !!include_seconds_or_options
end
@@ -1181,8 +1181,7 @@ def to_model
def initialize(object_name, object, template, options, block=nil)
if block
- message = "Giving a block to FormBuilder is deprecated and has no effect anymore."
- ActiveSupport::Deprecation.warn(message, caller)
+ ActiveSupport::Deprecation.warn "Giving a block to FormBuilder is deprecated and has no effect anymore."
end
@nested_child_index = {}
@@ -521,7 +521,7 @@ def grouped_options_for_select(grouped_options, selected_key = nil, options = {}
options = {}
message = "Passing the prompt to grouped_options_for_select as an argument is deprecated. " \
"Please use an options hash like `{ prompt: #{prompt.inspect} }`."
- ActiveSupport::Deprecation.warn(message, caller)
+ ActiveSupport::Deprecation.warn message
end
body = "".html_safe
@@ -427,15 +427,15 @@ def submit_tag(value = "Save changes", options = {})
if disable_with = options.delete("disable_with")
message = ":disable_with option is deprecated and will be removed from Rails 4.1. " \
"Use 'data: { disable_with: \'Text\' }' instead."
- ActiveSupport::Deprecation.warn(message, caller)
+ ActiveSupport::Deprecation.warn message
options["data-disable-with"] = disable_with
end
if confirm = options.delete("confirm")
message = ":confirm option is deprecated and will be removed from Rails 4.1. " \
"Use 'data: { confirm: \'Text\' }' instead'."
- ActiveSupport::Deprecation.warn(message, caller)
+ ActiveSupport::Deprecation.warn message
options["data-confirm"] = confirm
end
@@ -489,15 +489,15 @@ def button_tag(content_or_options = nil, options = nil, &block)
if disable_with = options.delete("disable_with")
message = ":disable_with option is deprecated and will be removed from Rails 4.1. " \
"Use 'data: { disable_with: \'Text\' }' instead."
- ActiveSupport::Deprecation.warn(message, caller)
+ ActiveSupport::Deprecation.warn message
options["data-disable-with"] = disable_with
end
if confirm = options.delete("confirm")
message = ":confirm option is deprecated and will be removed from Rails 4.1. " \
"Use 'data: { confirm: \'Text\' }' instead'."
- ActiveSupport::Deprecation.warn(message, caller)
+ ActiveSupport::Deprecation.warn message
options["data-confirm"] = confirm
end
@@ -543,7 +543,7 @@ def image_submit_tag(source, options = {})
if confirm = options.delete("confirm")
message = ":confirm option is deprecated and will be removed from Rails 4.1. " \
"Use 'data: { confirm: \'Text\' }' instead'."
- ActiveSupport::Deprecation.warn(message, caller)
+ ActiveSupport::Deprecation.warn message
options["data-confirm"] = confirm
end
@@ -80,7 +80,7 @@ def javascript_cdata_section(content) #:nodoc:
def button_to_function(name, function=nil, html_options={})
message = "button_to_function is deprecated and will be removed from Rails 4.1. We recomend to use Unobtrusive JavaScript instead. " +
"See http://guides.rubyonrails.org/working_with_javascript_in_rails.html#unobtrusive-javascript"
- ActiveSupport::Deprecation.warn(message, caller)
+ ActiveSupport::Deprecation.warn message
onclick = "#{"#{html_options[:onclick]}; " if html_options[:onclick]}#{function};"
@@ -102,7 +102,7 @@ def button_to_function(name, function=nil, html_options={})
def link_to_function(name, function, html_options={})
message = "link_to_function is deprecated and will be removed from Rails 4.1. We recomend to use Unobtrusive JavaScript instead. " +
"See http://guides.rubyonrails.org/working_with_javascript_in_rails.html#unobtrusive-javascript"
- ActiveSupport::Deprecation.warn(message, caller)
+ ActiveSupport::Deprecation.warn message
onclick = "#{"#{html_options[:onclick]}; " if html_options[:onclick]}#{function}; return false;"
href = html_options[:href] || '#'
@@ -579,7 +579,7 @@ def convert_options_to_data_attributes(options, html_options)
if confirm
message = ":confirm option is deprecated and will be removed from Rails 4.1. " \
"Use 'data: { confirm: \'Text\' }' instead."
- ActiveSupport::Deprecation.warn(message, caller)
+ ActiveSupport::Deprecation.warn message
html_options["data-confirm"] = confirm
end
@@ -589,7 +589,7 @@ def convert_options_to_data_attributes(options, html_options)
if disable_with
message = ":disable_with option is deprecated and will be removed from Rails 4.1. " \
"Use 'data: { disable_with: \'Text\' }' instead."
- ActiveSupport::Deprecation.warn(message, caller)
+ ActiveSupport::Deprecation.warn message
html_options["data-disable-with"] = disable_with
end
@@ -150,7 +150,7 @@ def render(view, locals, buffer=nil, &block)
def mime_type
message = 'Template#mime_type is deprecated and will be removed in Rails 4.1. Please use type method instead.'
- ActiveSupport::Deprecation.warn(message, caller)
+ ActiveSupport::Deprecation.warn message
@mime_type ||= Mime::Type.lookup_by_extension(@formats.first.to_s) if @formats.first
end
@@ -237,7 +237,7 @@ def extract_handler_and_format(path, default_formats)
unless extension
message = "The file #{path} did not specify a template handler. The default is currently ERB, " \
"but will change to RAW in the future."
- ActiveSupport::Deprecation.warn(message, caller)
+ ActiveSupport::Deprecation.warn message
end
handler = Template.handler_for_extension(extension)
@@ -387,7 +387,7 @@ def initialize(options = {})
"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)
+ ActiveSupport::Deprecation.warn message
end
@prefix, @suffix = options.fetch(:prefix, ''), options.fetch(:suffix, '')
@@ -172,7 +172,7 @@ def observers_count
# <tt>count_observers</tt> is deprecated. Use #observers_count.
def count_observers
msg = "count_observers is deprecated in favor of observers_count"
- ActiveSupport::Deprecation.warn(msg, caller)
+ ActiveSupport::Deprecation.warn msg
observers_count
end
@@ -85,7 +85,7 @@ def scope
end
def scoped
- ActiveSupport::Deprecation.warn("#scoped is deprecated. use #scope instead.", caller)
+ ActiveSupport::Deprecation.warn "#scoped is deprecated. use #scope instead."
scope
end
@@ -46,7 +46,7 @@ def serialize(attr_name, class_name = Object)
def serialized_attributes
message = "Instance level serialized_attributes method is deprecated, please use class level method."
- ActiveSupport::Deprecation.warn(message, caller)
+ ActiveSupport::Deprecation.warn message
defined?(@serialized_attributes) ? @serialized_attributes : self.class.serialized_attributes
end
@@ -3,7 +3,7 @@
require 'bigdecimal/util'
require 'active_support/core_ext/benchmark'
require 'active_record/connection_adapters/schema_cache'
-require 'active_record/connection_adapters/abstract/schema_dumper'
+require 'active_record/connection_adapters/abstract/schema_dumper'
require 'monitor'
require 'active_support/deprecation'
@@ -255,16 +255,16 @@ def open_transactions
end
def increment_open_transactions
- ActiveSupport::Deprecation.warn("#increment_open_transactions is deprecated and has no effect", caller)
+ ActiveSupport::Deprecation.warn "#increment_open_transactions is deprecated and has no effect"
end
def decrement_open_transactions
- ActiveSupport::Deprecation.warn("#decrement_open_transactions is deprecated and has no effect", caller)
+ ActiveSupport::Deprecation.warn "#decrement_open_transactions is deprecated and has no effect"
end
def transaction_joinable=(joinable)
message = "#transaction_joinable= is deprecated. Please pass the :joinable option to #begin_transaction instead."
- ActiveSupport::Deprecation.warn(message, caller)
+ ActiveSupport::Deprecation.warn message
@transaction.joinable = joinable
end
@@ -109,7 +109,7 @@ def type_cast(value)
def type_cast_code(var_name)
message = "Column#type_cast_code is deprecated in favor of using Column#type_cast only, " \
"and it is going to be removed in future Rails versions."
- ActiveSupport::Deprecation.warn(message, caller)
+ ActiveSupport::Deprecation.warn message
klass = self.class.name
@@ -223,7 +223,7 @@ def rollback_db_transaction
def outside_transaction?
message = "#outside_transaction? is deprecated. This method was only really used " \
"internally, but you can use #transaction_open? instead."
- ActiveSupport::Deprecation.warn(message, caller)
+ ActiveSupport::Deprecation.warn message
@connection.transaction_status == PGconn::PQTRANS_IDLE
end
@@ -733,7 +733,7 @@ def migrate
if block_given?
message = "block argument to migrate is deprecated, please filter migrations before constructing the migrator"
- ActiveSupport::Deprecation.warn(message, caller)
+ ActiveSupport::Deprecation.warn message
running.select! { |m| yield m }
end
@@ -23,7 +23,7 @@ def readonly_attributes
def _attr_readonly
message = "Instance level _attr_readonly method is deprecated, please use class level method."
- ActiveSupport::Deprecation.warn(message, caller)
+ ActiveSupport::Deprecation.warn message
defined?(@_attr_readonly) ? @_attr_readonly : self.class._attr_readonly
end
end
@@ -95,8 +95,7 @@ def default_scope(scope = nil)
"Calling #default_scope without a block is deprecated. For example instead " \
"of `default_scope where(color: 'red')`, please use " \
"`default_scope { where(color: 'red') }`. (Alternatively you can just redefine " \
- "self.default_scope.)",
- caller
+ "self.default_scope.)"
)
end
@@ -156,8 +156,7 @@ def scope(name, body, &block)
"`scope :red, -> { where(color: 'red') }`. There are numerous gotchas " \
"in the former usage and it makes the implementation more complicated " \
"and buggy. (If you prefer, you can just define a class method named " \
- "`self.red`.)",
- caller
+ "`self.red`.)"
)
end
@@ -1,5 +1,10 @@
## Rails 4.0.0 (unreleased) ##
+* Make callstack attribute optional in
+ ActiveSupport::Deprecation::Reporting methods `warn` and `deprecation_warning`
+
+ *Alexey Gaziev*
+
* Implement HashWithIndifferentAccess#replace so key? works correctly. *David Graham*
* Handle the possible Permission Denied errors atomic.rb might trigger due to its chown and chmod calls. *Daniele Sluijters*
@@ -49,7 +49,7 @@ def benchmark(message = "Benchmarking", options = {})
# Silence the logger during the execution of the block.
def silence
message = "ActiveSupport::Benchmarkable#silence is deprecated. It will be removed from Rails 4.1."
- ActiveSupport::Deprecation.warn(message, caller)
+ ActiveSupport::Deprecation.warn message
old_logger_level, logger.level = logger.level, ::Logger::ERROR if logger
yield
ensure
@@ -284,13 +284,13 @@ def _normalize_legacy_filter(kind, filter)
if !filter.respond_to?(kind) && filter.respond_to?(:filter)
message = "Filter object with #filter method is deprecated. Define method corresponding " \
"to filter type (#before, #after or #around)."
- ActiveSupport::Deprecation.warn(message, caller)
+ ActiveSupport::Deprecation.warn message
filter.singleton_class.class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
def #{kind}(context, &block) filter(context, &block) end
RUBY_EVAL
elsif filter.respond_to?(:before) && filter.respond_to?(:after) && kind == :around && !filter.respond_to?(:around)
message = "Filter object with #before and #after methods is deprecated. Define #around method instead."
- ActiveSupport::Deprecation.warn(message, caller)
+ ActiveSupport::Deprecation.warn message
def filter.around(context)
should_continue = before(context)
yield if should_continue
@@ -5,15 +5,15 @@ class Array
#
# [1, 2, 3, 4].uniq_by { |i| i.odd? } # => [1, 2]
def uniq_by(&block)
- ActiveSupport::Deprecation.warn 'uniq_by is deprecated. Use Array#uniq instead', caller
+ ActiveSupport::Deprecation.warn 'uniq_by is deprecated. Use Array#uniq instead'
uniq(&block)
end
# *DEPRECATED*: Use +Array#uniq!+ instead.
#
# Same as +uniq_by+, but modifies +self+.
def uniq_by!(&block)
- ActiveSupport::Deprecation.warn 'uniq_by! is deprecated. Use Array#uniq! instead', caller
+ ActiveSupport::Deprecation.warn 'uniq_by! is deprecated. Use Array#uniq! instead'
uniq!(&block)
end
end
@@ -4,7 +4,7 @@ class DateTime
class << self
# *DEPRECATED*: Use +DateTime.civil_from_format+ directly.
def local_offset
- ActiveSupport::Deprecation.warn 'DateTime.local_offset is deprecated. Use DateTime.civil_from_format directly.', caller
+ ActiveSupport::Deprecation.warn 'DateTime.local_offset is deprecated. Use DateTime.civil_from_format directly.'
::Time.local(2012).utc_offset.to_r / 86400
end
@@ -72,7 +72,7 @@ def local_constants #:nodoc:
# This method is useful for forward compatibility, since Ruby 1.8 returns
# constant names as strings, whereas 1.9 returns them as symbols.
def local_constant_names
- ActiveSupport::Deprecation.warn 'Module#local_constant_names is deprecated, use Module#local_constants instead', caller
+ ActiveSupport::Deprecation.warn 'Module#local_constant_names is deprecated, use Module#local_constants instead'
local_constants.map { |c| c.to_s }
end
end
@@ -3,7 +3,7 @@
class Proc #:nodoc:
def bind(object)
- ActiveSupport::Deprecation.warn 'Proc#bind is deprecated and will be removed in future versions', caller
+ ActiveSupport::Deprecation.warn 'Proc#bind is deprecated and will be removed in future versions'
block, time = self, Time.now
object.class_eval do
@@ -2,7 +2,7 @@
class String
def encoding_aware?
- ActiveSupport::Deprecation.warn 'String#encoding_aware? is deprecated', caller
+ ActiveSupport::Deprecation.warn 'String#encoding_aware? is deprecated'
true
end
end
@@ -33,7 +33,7 @@ def deprecate_methods(target_module, *method_names)
method_names.each do |method_name|
target_module.alias_method_chain(method_name, :deprecation) do |target, punctuation|
target_module.send(:define_method, "#{target}_with_deprecation#{punctuation}") do |*args, &block|
- deprecator.deprecation_warning(method_name, options[method_name], caller)
+ deprecator.deprecation_warning(method_name, options[method_name])
send(:"#{target}_without_deprecation#{punctuation}", *args, &block)
end
end
Oops, something went wrong.

0 comments on commit b955939

Please sign in to comment.