Class: Keep::Yaml
Instance Attribute Summary
Attributes inherited from Disk
Instance Method Summary collapse
-
#data ⇒ Object
The in-memory data structure representing the configuration you’re keeping.
-
#save ⇒ Object
Persists the in-memory hash to disk.
Methods inherited from Disk
#get, #initialize, #keys, #present?, #set, #touch
Constructor Details
This class inherits a constructor from Keep::Disk
Instance Method Details
#data ⇒ Object
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 |
#save ⇒ Object
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 |