Class: HashPipe::Backends::Filesystem

Inherits:
Object
  • Object
show all
Defined in:
lib/hashpipe/backends/filesystem.rb

Overview

The filesystem backend is mostly useful for development or test work. It’s not currently sharded in any way, so would probably have serious issues for production use. You have been warned.

Instance Method Summary collapse

Constructor Details

#initialize(archived_attribute) ⇒ Filesystem

Returns a new instance of Filesystem.



8
9
10
# File 'lib/hashpipe/backends/filesystem.rb', line 8

def initialize(archived_attribute)
  @archived_attribute = archived_attribute
end

Instance Method Details

#destroyObject



17
18
19
# File 'lib/hashpipe/backends/filesystem.rb', line 17

def destroy
  FileUtils.rm_f(filename)
end

#filenameObject

Returns the full file path + name of this archived attribute



26
27
28
# File 'lib/hashpipe/backends/filesystem.rb', line 26

def filename
  File.join(filepath, @archived_attribute.name.to_s)
end

#loadObject



21
22
23
# File 'lib/hashpipe/backends/filesystem.rb', line 21

def load
  File.read( filename ) if File.exist?( filename )
end

#save(content) ⇒ Object



12
13
14
15
# File 'lib/hashpipe/backends/filesystem.rb', line 12

def save(content)
  create_filesystem_path unless File.exist?(filepath)
  write_to_disk(content)
end