class NonConfig::ConfigFile

Hash with filepath and {#save} method

Attributes

path[R]

Public Class Methods

new(path = nil) click to toggle source

parses yaml from path

Calls superclass method
# File lib/non_config/config_file.rb, line 13
def initialize(path = nil)
  super()
  return unless path
  fail FileNotFound unless File.exist? path

  @path = path
  file_data = File.read @path
  records = YAML.load file_data
  merge! self.class.from_hash(records)
end

Public Instance Methods

save() click to toggle source

rewrite file so you can save your changes

# File lib/non_config/config_file.rb, line 25
def save
  File.open(@path, 'w') { |f| f.write to_yaml }
end