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:



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

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

Instance Method Details

#marshal_dumpObject



71
72
73
# File 'lib/mime/types/cache.rb', line 71

def marshal_dump
  {}.merge(self)
end

#marshal_load(hash) ⇒ Object



75
76
77
78
# File 'lib/mime/types/cache.rb', line 75

def marshal_load(hash)
  self.default_proc = ->(h, k) { h[k] = [] }
  self.merge!(hash)
end