aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/deprecated_associations.rb
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2006-09-15 07:02:05 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2006-09-15 07:02:05 +0000
commit3f1acf49bd4cfa902388f000ca96c848c3666017 (patch)
treeaf197c1f4ea786e76da1f0679225572ea1953a58 /activerecord/lib/active_record/deprecated_associations.rb
parentd0c000ab9e90be4896744cb6ec107dffa573f2dd (diff)
downloadrails-3f1acf49bd4cfa902388f000ca96c848c3666017.tar.gz
rails-3f1acf49bd4cfa902388f000ca96c848c3666017.tar.bz2
rails-3f1acf49bd4cfa902388f000ca96c848c3666017.zip
Deprecation tests. Remove warnings for dynamic finders and for the foo_count ethod if it's also an attribute.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5116 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record/deprecated_associations.rb')
-rw-r--r--activerecord/lib/active_record/deprecated_associations.rb34
1 files changed, 24 insertions, 10 deletions
diff --git a/activerecord/lib/active_record/deprecated_associations.rb b/activerecord/lib/active_record/deprecated_associations.rb
index 077ac1de3b..4a0918c824 100644
--- a/activerecord/lib/active_record/deprecated_associations.rb
+++ b/activerecord/lib/active_record/deprecated_associations.rb
@@ -4,65 +4,77 @@ module ActiveRecord
def deprecated_collection_count_method(collection_name)# :nodoc:
module_eval <<-"end_eval", __FILE__, __LINE__
def #{collection_name}_count(force_reload = false)
+ unless has_attribute?(:#{collection_name}_count)
+ ActiveSupport::Deprecation.warn :#{collection_name}_count
+ end
#{collection_name}.reload if force_reload
#{collection_name}.size
end
end_eval
end
-
+
def deprecated_add_association_relation(association_name)# :nodoc:
module_eval <<-"end_eval", __FILE__, __LINE__
def add_#{association_name}(*items)
#{association_name}.concat(items)
end
+ deprecate :add_#{association_name}
end_eval
end
-
+
def deprecated_remove_association_relation(association_name)# :nodoc:
module_eval <<-"end_eval", __FILE__, __LINE__
def remove_#{association_name}(*items)
#{association_name}.delete(items)
end
+ deprecate :remove_#{association_name}
end_eval
end
-
+
def deprecated_has_collection_method(collection_name)# :nodoc:
module_eval <<-"end_eval", __FILE__, __LINE__
def has_#{collection_name}?(force_reload = false)
!#{collection_name}(force_reload).empty?
end
+ deprecate :has_#{collection_name}?
end_eval
end
-
+
def deprecated_find_in_collection_method(collection_name)# :nodoc:
module_eval <<-"end_eval", __FILE__, __LINE__
def find_in_#{collection_name}(association_id)
#{collection_name}.find(association_id)
end
+ deprecate :find_in_#{collection_name}
end_eval
end
-
+
def deprecated_find_all_in_collection_method(collection_name)# :nodoc:
module_eval <<-"end_eval", __FILE__, __LINE__
def find_all_in_#{collection_name}(runtime_conditions = nil, orderings = nil, limit = nil, joins = nil)
- #{collection_name}.find_all(runtime_conditions, orderings, limit, joins)
+ ActiveSupport::Deprecation.silence do
+ #{collection_name}.find_all(runtime_conditions, orderings, limit, joins)
+ end
end
+ deprecate :find_all_in_#{collection_name}
end_eval
end
-
+
def deprecated_collection_create_method(collection_name)# :nodoc:
module_eval <<-"end_eval", __FILE__, __LINE__
def create_in_#{collection_name}(attributes = {})
#{collection_name}.create(attributes)
end
+ deprecate :create_in_#{collection_name}
end_eval
end
-
+
def deprecated_collection_build_method(collection_name)# :nodoc:
module_eval <<-"end_eval", __FILE__, __LINE__
def build_to_#{collection_name}(attributes = {})
#{collection_name}.build(attributes)
end
+ deprecate :build_to_#{collection_name}
end_eval
end
@@ -75,16 +87,18 @@ module ActiveRecord
raise "Comparison object is a #{association_class_name}, should have been \#{comparison_object.class.name}"
end
end
+ deprecate :#{association_name}?
end_eval
end
-
+
def deprecated_has_association_method(association_name) # :nodoc:
module_eval <<-"end_eval", __FILE__, __LINE__
def has_#{association_name}?(force_reload = false)
!#{association_name}(force_reload).nil?
end
+ deprecate :has_#{association_name}?
end_eval
- end
+ end
end
end
end