lib/mixlib/config.rb in mixlib-config-3.0.9 vs lib/mixlib/config.rb in mixlib-config-3.0.27
- old
+ new
@@ -563,13 +563,16 @@
#
# This is preferable to converting it to the string representation with
# the #to_dotted_hash method above.
#
# === Parameters
- # hash<Hash>:: The hash to apply to the config oject
+ # hash<Hash>:: The hash to apply to the config object
def apply_nested_hash(hash)
hash.each do |k, v|
- if v.is_a? Hash
+ if v.is_a?(Hash) && internal_get(k.to_sym).is_a?(Hash)
+ # If it is a plain config key (not a context) and the value is a Hash, plain merge the Hashes.
+ internal_set(k.to_sym, internal_get(k.to_sym).merge(v))
+ elsif v.is_a? Hash
# If loading from hash, and we reference a context that doesn't exist
# and warning/strict is off, we need to create the config context that we expected to be here.
context = internal_get(k.to_sym) || config_context(k.to_sym)
context.apply_nested_hash(v)
else