Skip to content

Commit

Permalink
Merge pull request #28 from mvpopa/params_merging_optional
Browse files Browse the repository at this point in the history
optionally override parameters on addition
  • Loading branch information
derks committed Jun 24, 2015
2 parents 1f47e67 + 3a50c0c commit c55afb8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/parseconfig.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,15 @@ def get_groups()

# This method adds an element to the config object (not the config file)
# By adding a Hash, you create a new group
def add(param_name, value)
def add(param_name, value, override = false)
if value.class == Hash
if self.params.has_key?(param_name)
if self.params[param_name].class == Hash
self.params[param_name].merge!(value)
if override
self.params[param_name] = value
else
self.params[param_name].merge!(value)
end
elsif self.params.has_key?(param_name)
if self.params[param_name].class != value.class
raise ArgumentError, "#{param_name} already exists, and is of different type!"
Expand Down

0 comments on commit c55afb8

Please sign in to comment.