class MIME::Types::Container

:nodoc:
Marshal serialization (and does not survive the round-trip).
Hash#default_proc cannot be used without a wrapper because it prevents
format (plus, a default of a mutable object resuls in a shared mess).
the Marshal format correctly, it will not survive any other serialization
on a key miss. Hash#default_value cannot be used because, while it traverses
MIME::Types requires a serializable keyed container that returns an empty Set

def ==(other)

def ==(other)
  container == other
end

def [](key)

def [](key)
  container[key] || EMPTY_SET
end

def []=(key, value)

def []=(key, value)
  container[key] =
    case value
    when Set
      value
    else
      Set[*value]
    end
end

def add(key, value)

def add(key, value)
  (container[key] ||= Set.new).add(value)
end

def count(*args, &block)

def count(*args, &block)
  if args.size == 0
    container.count
  elsif block
    container.count(&block)
  else
    container.count(args.first)
  end
end

def each_pair(&block)

def each_pair(&block)
  container.each_pair(&block)
end

def each_value(&block)

def each_value(&block)
  container.each_value(&block)
end

def empty?

def empty?
  container.empty?
end

def encode_with(coder)

def encode_with(coder)
  container.each { |k, v| coder[k] = v.to_a }
end

def flat_map(&block)

def flat_map(&block)
  container.flat_map(&block)
end

def init_with(coder)

def init_with(coder)
  @container = {}
  coder.map.each { |k, v| container[k] = Set[*v] }
end

def initialize(hash = {})

:nodoc:
Marshal serialization (and does not survive the round-trip).
Hash#default_proc cannot be used without a wrapper because it prevents
format (plus, a default of a mutable object resuls in a shared mess).
the Marshal format correctly, it will not survive any other serialization
on a key miss. Hash#default_value cannot be used because, while it traverses
MIME::Types requires a serializable keyed container that returns an empty Set
def initialize(hash = {})
  @container = {}
  merge!(hash)
end

def keys

def keys
  container.keys
end

def marshal_dump

def marshal_dump
  {}.merge(container)
end

def marshal_load(hash)

def marshal_load(hash)
  @container = hash
end

def merge(other)

def merge(other)
  self.class.new(other)
end

def merge!(other)

def merge!(other)
  tap {
    other = other.is_a?(MIME::Types::Container) ? other.container : other
    container.merge!(other)
    normalize
  }
end

def normalize

def normalize
  container.each do |k, v|
    next if v.is_a?(Set)
    container[k] = Set[*v]
  end
end

def select(&block)

def select(&block)
  container.select(&block)
end

def to_hash

def to_hash
  container
end

def values

def values
  container.values
end