Sha256: 38c2b68dfa930ae1d466b823aed1479d3b20f6e207f582407949dba97ab4b582
Contents?: true
Size: 994 Bytes
Versions: 5
Compression:
Stored size: 994 Bytes
Contents
# @note The multimap gem was yanked, so we re-implement its functionality. # @see https://github.com/josh/multimap module MultiMail class Multimap def initialize @hash = {} end def [](key) @hash[key] end def []=(key, value) @hash[key] ||= [] @hash[key] << value end def ==(other) if Multimap === other @hash == other.hash else @hash == other end end def size @hash.values.flatten.size end def each_pair @hash.each_pair do |key,values| values.each do |value| yield key, value end end end def merge(other) dup.update(other) end def update(other) if Multimap === other other.each_pair do |key,value| self[key] = value end else raise ArgumentError end self end def to_hash @hash.dup end protected def hash @hash end end end
Version data entries
5 entries across 5 versions & 1 rubygems