Method: MemStore::ObjectStore.from_binary
- Defined in:
- lib/memstore/objectstore.rb
.from_binary(binary) ⇒ Object
Restores a data store from binary format.
binary - Binary data containing a serialized instance of ObjectStore.
Examples
store = ObjectStore.from_binary(IO.read(file))
Returns instance of ObjectStore
or nil if marshalling failed or marshalled object isn’t an ObjectStore.
Raises whatever Marshal::load raises.
158 159 160 161 |
# File 'lib/memstore/objectstore.rb', line 158 def self.from_binary(binary) restored = Marshal.load(binary) rescue nil if restored.instance_of?(ObjectStore) then restored else nil end end |