提交 f6de8065 编写于 作者: E Emilio Tagua 提交者: Santiago Pastorino

Refactor association_collection uniq method.

Signed-off-by: NSantiago Pastorino <santiago@wyeworks.com>
上级 2da809da
......@@ -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+
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册