Refactor association_collection uniq method.

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
This commit is contained in:
Emilio Tagua 2010-09-22 11:22:49 -03:00 committed by Santiago Pastorino
parent 2da809da37
commit f6de806537

@ -338,13 +338,12 @@ def many?
def uniq(collection = self)
seen = Set.new
collection.inject([]) do |kept, record|
collection.map do |record|
unless seen.include?(record.id)
kept << record
seen << record.id
record
end
kept
end
end.compact
end
# Replace this collection with +other_array+