diff options
author | Eloy Duran <eloy.de.enige@gmail.com> | 2010-01-08 21:44:06 +0100 |
---|---|---|
committer | Eloy Duran <eloy.de.enige@gmail.com> | 2010-01-08 21:47:17 +0100 |
commit | 7f775ef1a92129fcc77079bc8e00c99a75b38a38 (patch) | |
tree | 549b2e03c1fbaa8890a70e30c4c5370160c7daaf /activerecord | |
parent | f2aacd51405724cdf7cfd36a439c9dbfce16973a (diff) | |
download | rails-7f775ef1a92129fcc77079bc8e00c99a75b38a38.tar.gz rails-7f775ef1a92129fcc77079bc8e00c99a75b38a38.tar.bz2 rails-7f775ef1a92129fcc77079bc8e00c99a75b38a38.zip |
Renamed AssociationReflection #collection_association? to #collection?.
Diffstat (limited to 'activerecord')
-rwxr-xr-x | activerecord/lib/active_record/associations.rb | 6 | ||||
-rw-r--r-- | activerecord/lib/active_record/autosave_association.rb | 2 | ||||
-rw-r--r-- | activerecord/lib/active_record/nested_attributes.rb | 2 | ||||
-rw-r--r-- | activerecord/lib/active_record/reflection.rb | 10 | ||||
-rw-r--r-- | activerecord/test/cases/reflection_test.rb | 8 |
5 files changed, 14 insertions, 14 deletions
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index 1320f5b624..aceb83044b 100755 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -1770,7 +1770,7 @@ module ActiveRecord end def using_limitable_reflections?(reflections) - reflections.collect(&:collection_association?).length.zero? + reflections.collect(&:collection?).length.zero? end def column_aliases(join_dependency) @@ -1843,7 +1843,7 @@ module ActiveRecord case associations when Symbol, String reflection = base.reflections[associations] - if reflection && reflection.collection_association? + if reflection && reflection.collection? records.each { |record| record.send(reflection.name).target.uniq! } end when Array @@ -1857,7 +1857,7 @@ module ActiveRecord parent_records = [] records.each do |record| if descendant = record.send(reflection.name) - if reflection.collection_association? + if reflection.collection? parent_records.concat descendant.target.uniq else parent_records << descendant diff --git a/activerecord/lib/active_record/autosave_association.rb b/activerecord/lib/active_record/autosave_association.rb index f7119a77cc..7c4e81a617 100644 --- a/activerecord/lib/active_record/autosave_association.rb +++ b/activerecord/lib/active_record/autosave_association.rb @@ -166,7 +166,7 @@ module ActiveRecord def add_autosave_association_callbacks(reflection) save_method = :"autosave_associated_records_for_#{reflection.name}" validation_method = :"validate_associated_records_for_#{reflection.name}" - collection = reflection.collection_association? + collection = reflection.collection? unless method_defined?(save_method) if collection diff --git a/activerecord/lib/active_record/nested_attributes.rb b/activerecord/lib/active_record/nested_attributes.rb index 9038888d22..f79a12a95c 100644 --- a/activerecord/lib/active_record/nested_attributes.rb +++ b/activerecord/lib/active_record/nested_attributes.rb @@ -238,7 +238,7 @@ module ActiveRecord reflection.options[:autosave] = true add_autosave_association_callbacks(reflection) nested_attributes_options[association_name.to_sym] = options - type = (reflection.collection_association? ? :collection : :one_to_one) + type = (reflection.collection? ? :collection : :one_to_one) # def pirate_attributes=(attributes) # assign_nested_attributes_for_one_to_one_association(:pirate, attributes) diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb index d6fad5cf29..32b9a2aa87 100644 --- a/activerecord/lib/active_record/reflection.rb +++ b/activerecord/lib/active_record/reflection.rb @@ -255,11 +255,11 @@ module ActiveRecord # Returns whether or not this association reflection is for a collection # association. Returns +true+ if the +macro+ is one of +has_many+ or # +has_and_belongs_to_many+, +false+ otherwise. - def collection_association? - if @collection_association.nil? - @collection_association = [:has_many, :has_and_belongs_to_many].include?(macro) + def collection? + if @collection.nil? + @collection = [:has_many, :has_and_belongs_to_many].include?(macro) end - @collection_association + @collection end # Returns whether or not the association should be validated as part of @@ -278,7 +278,7 @@ module ActiveRecord private def derive_class_name class_name = name.to_s.camelize - class_name = class_name.singularize if collection_association? + class_name = class_name.singularize if collection? class_name end diff --git a/activerecord/test/cases/reflection_test.rb b/activerecord/test/cases/reflection_test.rb index 774ab7aa4c..2c9158aa7b 100644 --- a/activerecord/test/cases/reflection_test.rb +++ b/activerecord/test/cases/reflection_test.rb @@ -198,11 +198,11 @@ class ReflectionTest < ActiveRecord::TestCase end def test_collection_association - assert Pirate.reflect_on_association(:birds).collection_association? - assert Pirate.reflect_on_association(:parrots).collection_association? + assert Pirate.reflect_on_association(:birds).collection? + assert Pirate.reflect_on_association(:parrots).collection? - assert !Pirate.reflect_on_association(:ship).collection_association? - assert !Ship.reflect_on_association(:pirate).collection_association? + assert !Pirate.reflect_on_association(:ship).collection? + assert !Ship.reflect_on_association(:pirate).collection? end def test_default_association_validation |