Class: Picky::Backends::Memory::Marshal
- Defined in:
- lib/picky/backends/memory/marshal.rb
Overview
Index data in the Ruby Marshal format.
Instance Attribute Summary
Attributes inherited from Basic
Instance Method Summary collapse
-
#dump(internal) ⇒ Object
Dumps the index internal backend in marshal format.
-
#dump_marshal(internal) ⇒ Object
Dumps binary self to the path given.
-
#extension ⇒ Object
Uses the extension “dump”.
-
#load(_) ⇒ Object
Loads the index hash from marshal format.
-
#retrieve ⇒ Object
A marshal file does not provide retrieve functionality.
Methods inherited from Basic
#cache_path, #delete, #empty, #initial, #initialize, #to_s, #type
Methods included from Helpers::File
Constructor Details
This class inherits a constructor from Picky::Backends::Memory::Basic
Instance Method Details
#dump(internal) ⇒ Object
Dumps the index internal backend in marshal format.
25 26 27 28 |
# File 'lib/picky/backends/memory/marshal.rb', line 25 def dump internal create_directory cache_path dump_marshal internal end |
#dump_marshal(internal) ⇒ Object
Dumps binary self to the path given. Minus extension.
32 33 34 35 36 |
# File 'lib/picky/backends/memory/marshal.rb', line 32 def dump_marshal internal ::File.open(cache_path, 'w:binary') do |out_file| ::Marshal.dump internal, out_file end end |
#extension ⇒ Object
Uses the extension “dump”.
13 14 15 |
# File 'lib/picky/backends/memory/marshal.rb', line 13 def extension :dump end |
#load(_) ⇒ Object
Loads the index hash from marshal format.
19 20 21 |
# File 'lib/picky/backends/memory/marshal.rb', line 19 def load _ ::Marshal.load ::File.open(cache_path, 'r:binary') end |
#retrieve ⇒ Object
A marshal file does not provide retrieve functionality.
40 41 42 |
# File 'lib/picky/backends/memory/marshal.rb', line 40 def retrieve raise "Can't retrieve from marshalled file. Use text file." end |