Permalink
Browse files

Renamed AssociationReflection #collection_association? to #collection?.

  • Loading branch information...
1 parent f2aacd5 commit 7f775ef1a92129fcc77079bc8e00c99a75b38a38 @alloy alloy committed Jan 8, 2010
@@ -1770,7 +1770,7 @@ def construct_finder_sql_for_association_limiting(options, join_dependency)
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 @@ 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
@@ -1857,7 +1857,7 @@ def remove_duplicate_results!(base, records, associations)
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
@@ -166,7 +166,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
@@ -238,7 +238,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)
@@ -255,11 +255,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
@@ -278,7 +278,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
@@ -198,11 +198,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 7f775ef

Please sign in to comment.