module ViewModel::Utils::Collections
def self.count_by(enumerable)
def self.count_by(enumerable) enumerable.each_with_object({}) do |el, counts| key = yield(el) unless key.nil? counts[key] = (counts[key] || 0) + 1 end end end
def self.count_by(enumerable) enumerable.each_with_object({}) do |el, counts| key = yield(el) unless key.nil? counts[key] = (counts[key] || 0) + 1 end end end