Class: Keep::Yaml

Inherits:
Disk
  • Object
show all
Defined in:
lib/keep/yaml.rb

Instance Attribute Summary

Attributes inherited from Disk

#path

Instance Method Summary collapse

Methods inherited from Disk

#get, #initialize, #keys, #present?, #set, #touch

Constructor Details

This class inherits a constructor from Keep::Disk

Instance Method Details

#dataObject

The in-memory data structure representing the configuration you’re keeping. Implemented by child classes.

Returns a Hash of configuration keys and values.



8
9
10
# File 'lib/keep/yaml.rb', line 8

def data
  @data ||= YAML::load_file(path) || {}
end

#saveObject

Persists the in-memory hash to disk. Implemented by child classes.

Returns whether the save was successful.



15
16
17
18
19
# File 'lib/keep/yaml.rb', line 15

def save
  File.open(path, 'w') do |out|
    YAML.dump(data, out)
  end
end