lib/mixlib/config.rb in mixlib-config-2.2.2 vs lib/mixlib/config.rb in mixlib-config-2.2.3
- old
+ new
@@ -1,10 +1,10 @@
#
-# Author:: Adam Jacob (<adam@opscode.com>)
-# Author:: Nuo Yan (<nuo@opscode.com>)
-# Author:: Christopher Brown (<cb@opscode.com>)
-# Copyright:: Copyright (c) 2008 Opscode, Inc.
+# Author:: Adam Jacob (<adam@chef.io>)
+# Author:: Nuo Yan (<nuo@chef.io>)
+# Author:: Christopher Brown (<cb@chef.io>)
+# Copyright:: Copyright (c) 2008-2016 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
@@ -175,19 +175,23 @@
result
end
# Restore non-default values from the given hash.
#
- # This method is the equivalent of +reset+ followed by +merge!(hash)+.
- #
# === Parameters
# hash<Hash>: a hash in the same format as output by save.
- #
+ #
# === Returns
# self
def restore(hash)
- reset
- merge!(hash)
+ self.configuration = hash.reject { |key, value| config_contexts.has_key?(key) }
+ config_contexts.each do |key, config_context|
+ if hash.has_key?(key)
+ config_context.restore(hash[key])
+ else
+ config_context.reset
+ end
+ end
end
# Merge an incoming hash with our config options
#
# === Parameters