Class: ArchivedAttributes::Backends::Filesystem

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

Instance Method Summary collapse

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

#destroyObject



15
16
17
# File 'lib/archived_attributes/backends/filesystem.rb', line 15

def destroy
  FileUtils.rm_f(filename)
end

#filenameObject

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

#loadObject



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