Class: ArchivedAttributes::Backends::Filesystem
- Inherits:
-
Object
- Object
- ArchivedAttributes::Backends::Filesystem
- Defined in:
- lib/archived_attributes/backends/filesystem.rb
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.
6 7 8 |
# File 'lib/archived_attributes/backends/filesystem.rb', line 6 def initialize(archived_attribute) @archived_attribute = archived_attribute end |
Instance Method Details
#destroy ⇒ Object
15 16 17 |
# File 'lib/archived_attributes/backends/filesystem.rb', line 15 def destroy FileUtils.rm_f(filename) end |
#filename ⇒ Object
Returns the full file path + name of this archived attribute
24 25 26 |
# File 'lib/archived_attributes/backends/filesystem.rb', line 24 def filename File.join(filepath, @archived_attribute.name.to_s) end |
#load ⇒ Object
19 20 21 |
# File 'lib/archived_attributes/backends/filesystem.rb', line 19 def load File.read( filename ) if File.exist?( filename ) end |
#save(content) ⇒ Object
10 11 12 13 |
# File 'lib/archived_attributes/backends/filesystem.rb', line 10 def save(content) create_filesystem_path unless File.exist?(filepath) write_to_disk(content) end |