Class: MIME::Types::Container

Inherits:
Hash
  • Object
show all
Defined in:
lib/mime/types/cache.rb

Overview

MIME::Types requires a container Hash with a default values for keys resulting in an empty array ([]), but this cannot be dumped through Marshal because of the presence of that default Proc. This class exists solely to satisfy that need.

Instance Method Summary collapse

Constructor Details

#initializeContainer

:nodoc:



60
61
62
63
# File 'lib/mime/types/cache.rb', line 60

def initialize
  super
  self.default_proc = ->(h, k) { h[k] = [] }
end

Instance Method Details

#marshal_dumpObject



65
66
67
# File 'lib/mime/types/cache.rb', line 65

def marshal_dump
  {}.merge(self)
end

#marshal_load(hash) ⇒ Object



69
70
71
# File 'lib/mime/types/cache.rb', line 69

def marshal_load(hash)
  self.merge!(hash)
end