Sha256: 69e07222ea76536d2c554a048c924727579125284b8bb57663588f4b8341afa8
Contents?: true
Size: 451 Bytes
Versions: 4
Compression:
Stored size: 451 Bytes
Contents
# Utility methods to create hashes from collections. # origin: RM module Enumerable def collect_hash(&pairer) collect_into_hash({}, &pairer) end def collect_ordered_hash(&pairer) collect_into_hash(ActiveSupport::OrderedHash.new, &pairer) end private def collect_into_hash(hash, &pairer) inject(hash) do |hash, key| pair = pairer.call(key) hash[pair[0]] = pair[1] unless pair.nil? hash end end end
Version data entries
4 entries across 4 versions & 1 rubygems