lib/hygroscope/paramset.rb in hygroscope-1.2.0 vs lib/hygroscope/paramset.rb in hygroscope-1.3.0

- old
+ new

@@ -10,24 +10,23 @@ def initialize(name = nil) @parameters = {} @path = File.join(Dir.pwd, 'paramsets') - if name - @name = name - self.load! - end + return unless name + + @name = name + load! end def load! files = Dir.glob(File.join(@path, @name + '.{yml,yaml}')) - if files.empty? - fail Hygroscope::ParamSetNotFoundError - else - @file = files.first - @parameters = YAML.load_file(@file) - end + + raise Hygroscope::ParamSetNotFoundError if files.empty? + + @file = files.first + @parameters = YAML.load_file(@file) end def save! # If this is a new paramset, construct a filename savefile = @file || File.join(@path, @name + '.yaml') @@ -38,10 +37,14 @@ def get(key) @parameters[key] end - def set(key, value) - @parameters[key] = value + def set(key, value, use_previous_value: false) + @parameters[key] = if use_previous_value + 'HYGROSCOPE_USE_PREVIOUS_VALUE' + else + value + end end end end