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

Version Path
kinetic_sdk-5.0.18 gems/mime-types-3.1/lib/mime/types/container.rb
kinetic_sdk-5.0.17 gems/mime-types-3.1/lib/mime/types/container.rb
kinetic_sdk-5.0.16 gems/mime-types-3.1/lib/mime/types/container.rb
kinetic_sdk-5.0.15 gems/mime-types-3.1/lib/mime/types/container.rb
kinetic_sdk-5.0.14 gems/mime-types-3.1/lib/mime/types/container.rb
kinetic_sdk-5.0.13 gems/mime-types-3.1/lib/mime/types/container.rb
kinetic_sdk-5.0.12 gems/mime-types-3.1/lib/mime/types/container.rb
kinetic_sdk-5.0.11 gems/mime-types-3.1/lib/mime/types/container.rb
kinetic_sdk-5.0.10 gems/mime-types-3.1/lib/mime/types/container.rb
kinetic_sdk-5.0.9 gems/mime-types-3.1/lib/mime/types/container.rb
kinetic_sdk-5.0.8 gems/mime-types-3.1/lib/mime/types/container.rb
kinetic_sdk-5.0.7 gems/mime-types-3.1/lib/mime/types/container.rb
kinetic_sdk-5.0.6 gems/mime-types-3.1/lib/mime/types/container.rb
kinetic_sdk-5.0.5 gems/mime-types-3.1/lib/mime/types/container.rb
kinetic_sdk-5.0.4 gems/mime-types-3.1/lib/mime/types/container.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.4.0/gems/mime-types-3.1/lib/mime/types/container.rb
kinetic_sdk-5.0.3 gems/mime-types-3.1/lib/mime/types/container.rb
kinetic_sdk-5.0.2 gems/mime-types-3.1/lib/mime/types/container.rb
kinetic_sdk-5.0.2.beta.4 gems/mime-types-3.1/lib/mime/types/container.rb
kinetic_sdk-5.0.2.beta.3 gems/mime-types-3.1/lib/mime/types/container.rb