Class: Bootscale::FileStorage

Inherits:
Object
  • Object
show all
Defined in:
lib/bootscale/file_storage.rb

Instance Method Summary collapse

Constructor Details

#initialize(directory) ⇒ FileStorage

Returns a new instance of FileStorage.



5
6
7
# File 'lib/bootscale/file_storage.rb', line 5

def initialize(directory)
  @directory = directory
end

Instance Method Details

#dump(load_path, cache) ⇒ Object



14
15
16
17
18
# File 'lib/bootscale/file_storage.rb', line 14

def dump(load_path, cache)
  path = cache_path(load_path)
  FileUtils.mkdir_p(File.dirname(path))
  File.write(path, Serializer.dump(cache), mode: 'wb+')
end

#load(load_path) ⇒ Object



9
10
11
12
# File 'lib/bootscale/file_storage.rb', line 9

def load(load_path)
  path = cache_path(load_path)
  Serializer.load(File.read(path)) if File.exist?(path)
end