Sha256: 6b434bc3b1c5c807c951bb85e418e4426154da199783710931f94045b1b15b26
Contents?: true
Size: 751 Bytes
Versions: 55
Compression:
Stored size: 751 Bytes
Contents
require 'set' # MIME::Types requires a container Hash with a default values for keys # resulting in an empty array (<tt>[]</tt>), but this cannot be dumped through # Marshal because of the presence of that default Proc. This class exists # solely to satisfy that need. class MIME::Types::Container < Hash # :nodoc: def initialize super self.default_proc = ->(h, k) { h[k] = Set.new } end def marshal_dump {}.merge(self) end def marshal_load(hash) self.default_proc = ->(h, k) { h[k] = Set.new } merge!(hash) end def encode_with(coder) each { |k, v| coder[k] = v.to_a } end def init_with(coder) self.default_proc = ->(h, k) { h[k] = Set.new } coder.map.each { |k, v| self[k] = Set[*v] } end end
Version data entries
55 entries across 51 versions & 9 rubygems