class AutoMarshallingMap
A map which automatically marshals all keys and values passed to it.
Attributes
backend[R]
backend
argument passed to new().
Public Class Methods
new(backend)
click to toggle source
backend
is a Map from String to
(String or nil). It will be used as a backend storage for the new AutoMarshallingMap.
# File lib/lib/auto_marshalling_map.rb, line 11 def initialize(backend) @backend = backend end
Public Instance Methods
[](key)
click to toggle source
# File lib/lib/auto_marshalling_map.rb, line 15 def [](key) value_string = @backend[Marshal.dump(key)] return nil if value_string.nil? return Marshal.load value_string end
[]=(key, value)
click to toggle source
# File lib/lib/auto_marshalling_map.rb, line 21 def []=(key, value) @backend[Marshal.dump(key)] = Marshal.dump(value) return value end