Class: MIME::Types::Container
- Inherits:
-
Hash
- Object
- Hash
- MIME::Types::Container
- 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
-
#initialize ⇒ Container
constructor
:nodoc:.
- #marshal_dump ⇒ Object
- #marshal_load(hash) ⇒ Object
Constructor Details
#initialize ⇒ Container
: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_dump ⇒ Object
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 |