Skip to content
Browse files

Renamed AssociationReflection #collection_association? to #collection?.

  • Loading branch information...
1 parent c9a3929 commit 51e6124e6a5fcb370201d49b042d336256fca61d @alloy alloy committed
View
6 activerecord/lib/active_record/associations.rb
@@ -1783,7 +1783,7 @@ def references_eager_loaded_tables?(options)
end
def using_limitable_reflections?(reflections)
- reflections.collect(&:collection_association?).length.zero?
+ reflections.collect(&:collection?).length.zero?
end
def column_aliases(join_dependency)
@@ -1860,7 +1860,7 @@ def remove_duplicate_results!(base, records, associations)
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
@@ -1874,7 +1874,7 @@ def remove_duplicate_results!(base, records, associations)
parent_records = records.map do |record|
descendant = record.send(reflection.name)
next unless descendant
- descendant.target.uniq! if reflection.collection_association?
+ descendant.target.uniq! if reflection.collection?
descendant
end.flatten.compact
View
2 activerecord/lib/active_record/autosave_association.rb
@@ -167,7 +167,7 @@ def #{type}(name, options = {})
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
View
2 activerecord/lib/active_record/nested_attributes.rb
@@ -234,7 +234,7 @@ def accepts_nested_attributes_for(*attr_names)
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)
View
10 activerecord/lib/active_record/reflection.rb
@@ -257,11 +257,11 @@ def polymorphic_inverse_of(associated_class)
# 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
@@ -280,7 +280,7 @@ def validate?
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
View
8 activerecord/test/cases/reflection_test.rb
@@ -188,11 +188,11 @@ def test_has_many_through_reflection
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

0 comments on commit 51e6124

Please sign in to comment.
Something went wrong with that request. Please try again.