summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoah Kantrowitz <noah@coderanger.net>2016-03-09 09:03:08 -0800
committerNoah Kantrowitz <noah@coderanger.net>2016-03-09 09:03:08 -0800
commit2e9dee22df33bafbcfcd4ee21a68cba37bcff52e (patch)
treeb6953fb5c51da7458e3c80bfd74e7f83a01d4019
parentdedb6ddaf84186be97d7436e2ccff7f4e52ee314 (diff)
downloadchef-2e9dee22df33bafbcfcd4ee21a68cba37bcff52e.tar.gz
Fix property coercion in both places, because they were different and
one in Chef::Mixin::Properties would result in duplicated values.
-rw-r--r--lib/chef/mixin/properties.rb2
-rw-r--r--lib/chef/property.rb2
2 files changed, 2 insertions, 2 deletions
diff --git a/lib/chef/mixin/properties.rb b/lib/chef/mixin/properties.rb
index 1ee16b8b4a..ae2406f1ae 100644
--- a/lib/chef/mixin/properties.rb
+++ b/lib/chef/mixin/properties.rb
@@ -95,7 +95,7 @@ class Chef
def property(name, type = NOT_PASSED, **options)
name = name.to_sym
- options.each { |k, v| options[k.to_sym] = v if k.is_a?(String) }
+ options = options.inject({}) { |memo, (key, value)| memo[key.to_sym] = value; memo }
options[:instance_variable_name] = :"@#{name}" if !options.has_key?(:instance_variable_name)
options[:name] = name
diff --git a/lib/chef/property.rb b/lib/chef/property.rb
index 0230c8b23b..95acdeea47 100644
--- a/lib/chef/property.rb
+++ b/lib/chef/property.rb
@@ -87,7 +87,7 @@ class Chef
# is fully initialized.
#
def initialize(**options)
- options.each { |k, v| options[k.to_sym] = v; options.delete(k) if k.is_a?(String) }
+ options = options.inject({}) { |memo, (key, value)| memo[key.to_sym] = value; memo }
@options = options
options[:name] = options[:name].to_sym if options[:name]
options[:instance_variable_name] = options[:instance_variable_name].to_sym if options[:instance_variable_name]