From e5684a28777c8bbfe472ac33fdbfddc7bdc1f9a7 Mon Sep 17 00:00:00 2001 From: Jamis Buck Date: Tue, 24 Oct 2006 17:25:30 +0000 Subject: [PATCH] update deprecations to include alternative methods (where available) git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5359 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- .../has_and_belongs_to_many_association.rb | 2 +- .../associations/has_many_association.rb | 4 ++-- activerecord/lib/active_record/base.rb | 4 ++-- .../active_record/deprecated_associations.rb | 18 +++++++++--------- .../lib/active_record/deprecated_finders.rb | 8 ++++---- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb b/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb index 8c0e50e38e..1eea798ab4 100644 --- a/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb +++ b/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb @@ -81,7 +81,7 @@ def push_with_attributes(record, join_attributes = {}) self end - deprecate :push_with_attributes + deprecate :push_with_attributes => "consider using has_many :through instead" alias :concat_with_attributes :push_with_attributes diff --git a/activerecord/lib/active_record/associations/has_many_association.rb b/activerecord/lib/active_record/associations/has_many_association.rb index 3cd6e5d716..0a275ab430 100644 --- a/activerecord/lib/active_record/associations/has_many_association.rb +++ b/activerecord/lib/active_record/associations/has_many_association.rb @@ -31,13 +31,13 @@ def find_all(runtime_conditions = nil, orderings = nil, limit = nil, joins = nil @reflection.klass.find_all(conditions, orderings, limit, joins) end end - deprecate :find_all + deprecate :find_all => "use find(:all, ...) instead" # DEPRECATED. Find the first associated record. All arguments are optional. def find_first(conditions = nil, orderings = nil) find_all(conditions, orderings, 1).first end - deprecate :find_first + deprecate :find_first => "use find(:first, ...) instead" # Count the number of associated records. All arguments are optional. def count(*args) diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 1cdebd93d9..d704caafc4 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -826,7 +826,7 @@ def quote_value(value, column = nil) #:nodoc: def quote(value, column = nil) #:nodoc: connection.quote(value, column) end - deprecate :quote + deprecate :quote => :quote_value # Used to sanitize objects before they're used in an SELECT SQL-statement. Delegates to connection.quote. def sanitize(object) #:nodoc: @@ -2012,7 +2012,7 @@ def quote_value(value, column = nil) def quote(value, column = nil) self.class.connection.quote(value, column) end - deprecate :quote + deprecate :quote => :quote_value # Interpolate custom sql string in instance context. diff --git a/activerecord/lib/active_record/deprecated_associations.rb b/activerecord/lib/active_record/deprecated_associations.rb index 4a0918c824..01410c4a7b 100644 --- a/activerecord/lib/active_record/deprecated_associations.rb +++ b/activerecord/lib/active_record/deprecated_associations.rb @@ -18,7 +18,7 @@ def deprecated_add_association_relation(association_name)# :nodoc: def add_#{association_name}(*items) #{association_name}.concat(items) end - deprecate :add_#{association_name} + deprecate :add_#{association_name} => "use #{association_name}.concat instead" end_eval end @@ -27,7 +27,7 @@ def deprecated_remove_association_relation(association_name)# :nodoc: def remove_#{association_name}(*items) #{association_name}.delete(items) end - deprecate :remove_#{association_name} + deprecate :remove_#{association_name} => "use #{association_name}.delete instead" end_eval end @@ -36,7 +36,7 @@ def deprecated_has_collection_method(collection_name)# :nodoc: def has_#{collection_name}?(force_reload = false) !#{collection_name}(force_reload).empty? end - deprecate :has_#{collection_name}? + deprecate :has_#{collection_name}? => "use !#{collection_name}.empty? instead" end_eval end @@ -45,7 +45,7 @@ def deprecated_find_in_collection_method(collection_name)# :nodoc: def find_in_#{collection_name}(association_id) #{collection_name}.find(association_id) end - deprecate :find_in_#{collection_name} + deprecate :find_in_#{collection_name} => "use #{collection_name}.find instead" end_eval end @@ -56,7 +56,7 @@ def find_all_in_#{collection_name}(runtime_conditions = nil, orderings = nil, li #{collection_name}.find_all(runtime_conditions, orderings, limit, joins) end end - deprecate :find_all_in_#{collection_name} + deprecate :find_all_in_#{collection_name} => "use #{collection_name}.find(:all, ...) instead" end_eval end @@ -65,7 +65,7 @@ def deprecated_collection_create_method(collection_name)# :nodoc: def create_in_#{collection_name}(attributes = {}) #{collection_name}.create(attributes) end - deprecate :create_in_#{collection_name} + deprecate :create_in_#{collection_name} => "use #{collection_name}.create instead" end_eval end @@ -74,7 +74,7 @@ def deprecated_collection_build_method(collection_name)# :nodoc: def build_to_#{collection_name}(attributes = {}) #{collection_name}.build(attributes) end - deprecate :build_to_#{collection_name} + deprecate :build_to_#{collection_name} => "use #{collection_name}.build instead" end_eval end @@ -87,7 +87,7 @@ def #{association_name}?(comparison_object, force_reload = false) raise "Comparison object is a #{association_class_name}, should have been \#{comparison_object.class.name}" end end - deprecate :#{association_name}? + deprecate :#{association_name}? => :== end_eval end @@ -96,7 +96,7 @@ def deprecated_has_association_method(association_name) # :nodoc: def has_#{association_name}?(force_reload = false) !#{association_name}(force_reload).nil? end - deprecate :has_#{association_name}? + deprecate :has_#{association_name}? => "use !#{association_name} insead" end_eval end end diff --git a/activerecord/lib/active_record/deprecated_finders.rb b/activerecord/lib/active_record/deprecated_finders.rb index 03b2b3d03f..4ab2dde5f0 100644 --- a/activerecord/lib/active_record/deprecated_finders.rb +++ b/activerecord/lib/active_record/deprecated_finders.rb @@ -10,7 +10,7 @@ class << self def find_on_conditions(ids, conditions) # :nodoc: find(ids, :conditions => conditions) end - deprecate :find_on_conditions + deprecate :find_on_conditions => "use find(ids, :conditions => conditions)" # This method is deprecated in favor of find(:first, options). # @@ -22,7 +22,7 @@ def find_on_conditions(ids, conditions) # :nodoc: def find_first(conditions = nil, orderings = nil, joins = nil) # :nodoc: find(:first, :conditions => conditions, :order => orderings, :joins => joins) end - deprecate :find_first + deprecate :find_first => "use find(:first, ...)" # This method is deprecated in favor of find(:all, options). # @@ -38,7 +38,7 @@ def find_all(conditions = nil, orderings = nil, limit = nil, joins = nil) # :nod limit, offset = limit.is_a?(Array) ? limit : [ limit, nil ] find(:all, :conditions => conditions, :order => orderings, :joins => joins, :limit => limit, :offset => offset) end - deprecate :find_all + deprecate :find_all => "use find(:all, ...)" end end -end \ No newline at end of file +end -- GitLab