Class: HashPipe::Backends::Filesystem
- Inherits:
-
Object
- Object
- HashPipe::Backends::Filesystem
- 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
- #destroy ⇒ Object
-
#filename ⇒ Object
Returns the full file path + name of this archived attribute.
-
#initialize(archived_attribute) ⇒ Filesystem
constructor
A new instance of Filesystem.
- #load ⇒ Object
- #save(content) ⇒ Object
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
#destroy ⇒ Object
17 18 19 |
# File 'lib/hashpipe/backends/filesystem.rb', line 17 def destroy FileUtils.rm_f(filename) end |
#filename ⇒ Object
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 |
#load ⇒ Object
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 |