lib/configstruct.rb in configstruct-0.0.3 vs lib/configstruct.rb in configstruct-0.0.4

- old
+ new

@@ -1,14 +1,15 @@ require 'ostruct' require 'yaml' class ConfigStruct < OpenStruct - def initialize(options = nil, input = STDIN, output = STDOUT) + def initialize(options = nil, input = STDIN, output = STDOUT, unless_set = false) super(options) @input = input @output = output + @unless_set = unless_set set_defaults prepare_dirs addvalues end @@ -22,11 +23,13 @@ end def addvalues setup unless File.exist? self.basefile YAML.load_file(self.basefile).each do |k, v| - new_ostruct_member(k) - send("#{k}=", v) + unless @unless_set && defined? self[v] + new_ostruct_member(k) + send("#{k}=", v) + end end end def setup write Hash.new