refactoring uniq method

This commit is contained in:
Aaron Patterson 2010-11-16 13:34:18 -08:00
parent 7ebd36d1c4
commit 59ba800698

@ -332,13 +332,10 @@ def many?
end
def uniq(collection = self)
seen = Set.new
collection.map do |record|
unless seen.include?(record.id)
seen << record.id
record
end
end.compact
seen = {}
collection.find_all do |record|
seen[record.id] = true unless seen.key?(record.id)
end
end
# Replace this collection with +other_array+