Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
39 lines (31 sloc) 513 Bytes
class ConfigStore
attr_reader :file
def initialize(file)
@file = file
end
def load
@config ||= YAML::load(open(file))
self
end
def [](key)
load
@config[key]
end
def []=(key, value)
@config[key] = value
end
def delete(*keys)
keys.each { |key| @config.delete(key) }
save
self
end
def update(c={})
@config.merge!(c)
save
self
end
def save
File.open(file, 'w') { |f| f.write(YAML.dump(@config)) }
self
end
end
Something went wrong with that request. Please try again.