Class: Bootscale::FileStorage
- Inherits:
-
Object
- Object
- Bootscale::FileStorage
- Defined in:
- lib/bootscale/file_storage.rb
Instance Method Summary collapse
- #dump(load_path, cache) ⇒ Object
-
#initialize(directory) ⇒ FileStorage
constructor
A new instance of FileStorage.
- #load(load_path) ⇒ Object
Constructor Details
#initialize(directory) ⇒ FileStorage
Returns a new instance of FileStorage.
6 7 8 |
# File 'lib/bootscale/file_storage.rb', line 6 def initialize(directory) @directory = directory end |
Instance Method Details
#dump(load_path, cache) ⇒ Object
15 16 17 18 19 |
# File 'lib/bootscale/file_storage.rb', line 15 def dump(load_path, cache) path = cache_path(load_path) FileUtils.mkdir_p(File.dirname(path)) Utils.atomic_write(path) { |f| f.write(Serializer.dump(cache)) } end |
#load(load_path) ⇒ Object
10 11 12 13 |
# File 'lib/bootscale/file_storage.rb', line 10 def load(load_path) path = cache_path(load_path) Serializer.load(File.read(path)) if File.exist?(path) end |