uniq_by()
public
Returns an unique array based on the criteria given as a Proc.
[1, 2, 3, 4].uniq_by { |i| i.odd? }
# File activesupport/lib/active_support/core_ext/array/uniq_by.rb, line 6
def uniq_by
hash, array = {}, []
each { |i| hash[yield(i)] ||= (array << i) }
array
end