Skip to content

Commit 7f775ef

Browse files
committed
Renamed AssociationReflection #collection_association? to #collection?.
1 parent f2aacd5 commit 7f775ef

File tree

5 files changed

+14
-14
lines changed

5 files changed

+14
-14
lines changed

activerecord/lib/active_record/associations.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1770,7 +1770,7 @@ def construct_finder_sql_for_association_limiting(options, join_dependency)
17701770
end
17711771

17721772
def using_limitable_reflections?(reflections)
1773-
reflections.collect(&:collection_association?).length.zero?
1773+
reflections.collect(&:collection?).length.zero?
17741774
end
17751775

17761776
def column_aliases(join_dependency)
@@ -1843,7 +1843,7 @@ def remove_duplicate_results!(base, records, associations)
18431843
case associations
18441844
when Symbol, String
18451845
reflection = base.reflections[associations]
1846-
if reflection && reflection.collection_association?
1846+
if reflection && reflection.collection?
18471847
records.each { |record| record.send(reflection.name).target.uniq! }
18481848
end
18491849
when Array
@@ -1857,7 +1857,7 @@ def remove_duplicate_results!(base, records, associations)
18571857
parent_records = []
18581858
records.each do |record|
18591859
if descendant = record.send(reflection.name)
1860-
if reflection.collection_association?
1860+
if reflection.collection?
18611861
parent_records.concat descendant.target.uniq
18621862
else
18631863
parent_records << descendant

activerecord/lib/active_record/autosave_association.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def #{type}(name, options = {})
166166
def add_autosave_association_callbacks(reflection)
167167
save_method = :"autosave_associated_records_for_#{reflection.name}"
168168
validation_method = :"validate_associated_records_for_#{reflection.name}"
169-
collection = reflection.collection_association?
169+
collection = reflection.collection?
170170

171171
unless method_defined?(save_method)
172172
if collection

activerecord/lib/active_record/nested_attributes.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ def accepts_nested_attributes_for(*attr_names)
238238
reflection.options[:autosave] = true
239239
add_autosave_association_callbacks(reflection)
240240
nested_attributes_options[association_name.to_sym] = options
241-
type = (reflection.collection_association? ? :collection : :one_to_one)
241+
type = (reflection.collection? ? :collection : :one_to_one)
242242

243243
# def pirate_attributes=(attributes)
244244
# assign_nested_attributes_for_one_to_one_association(:pirate, attributes)

activerecord/lib/active_record/reflection.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -255,11 +255,11 @@ def polymorphic_inverse_of(associated_class)
255255
# Returns whether or not this association reflection is for a collection
256256
# association. Returns +true+ if the +macro+ is one of +has_many+ or
257257
# +has_and_belongs_to_many+, +false+ otherwise.
258-
def collection_association?
259-
if @collection_association.nil?
260-
@collection_association = [:has_many, :has_and_belongs_to_many].include?(macro)
258+
def collection?
259+
if @collection.nil?
260+
@collection = [:has_many, :has_and_belongs_to_many].include?(macro)
261261
end
262-
@collection_association
262+
@collection
263263
end
264264

265265
# Returns whether or not the association should be validated as part of
@@ -278,7 +278,7 @@ def validate?
278278
private
279279
def derive_class_name
280280
class_name = name.to_s.camelize
281-
class_name = class_name.singularize if collection_association?
281+
class_name = class_name.singularize if collection?
282282
class_name
283283
end
284284

activerecord/test/cases/reflection_test.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,11 @@ def test_has_many_through_reflection
198198
end
199199

200200
def test_collection_association
201-
assert Pirate.reflect_on_association(:birds).collection_association?
202-
assert Pirate.reflect_on_association(:parrots).collection_association?
201+
assert Pirate.reflect_on_association(:birds).collection?
202+
assert Pirate.reflect_on_association(:parrots).collection?
203203

204-
assert !Pirate.reflect_on_association(:ship).collection_association?
205-
assert !Ship.reflect_on_association(:pirate).collection_association?
204+
assert !Pirate.reflect_on_association(:ship).collection?
205+
assert !Ship.reflect_on_association(:pirate).collection?
206206
end
207207

208208
def test_default_association_validation

0 commit comments

Comments
 (0)