diff options
author | John Keiser <john@johnkeiser.com> | 2015-09-22 22:15:19 -0700 |
---|---|---|
committer | John Keiser <john@johnkeiser.com> | 2015-09-22 22:50:28 -0700 |
commit | d8f7ca4d08f00db96fbf1e98a7f1ed763c7bab01 (patch) | |
tree | 73cec404209729267202b0e28ba888d84fc1046a /lib/chef/property.rb | |
parent | 0d93133c31704711b2bb6a20db74a83dc1b23493 (diff) | |
download | chef-d8f7ca4d08f00db96fbf1e98a7f1ed763c7bab01.tar.gz |
Honor the ordering of whichever `name_attribute` or `default` comes first
Diffstat (limited to 'lib/chef/property.rb')
-rw-r--r-- | lib/chef/property.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/chef/property.rb b/lib/chef/property.rb index 09198d90f1..5b6a969d5f 100644 --- a/lib/chef/property.rb +++ b/lib/chef/property.rb @@ -86,6 +86,21 @@ class Chef # def initialize(**options) options.each { |k,v| options[k.to_sym] = v if k.is_a?(String) } + # Only pick the first of :default, :name_property and :name_attribute if + # more than one is specified. + found_default = false + options.reject! do |k,v| + if [ :name_property, :name_attribute, :default ].include?(k) + if found_default + true + else + found_default = true + false + end + else + false + end + end options[:name_property] = options.delete(:name_attribute) if options.has_key?(:name_attribute) && !options.has_key?(:name_property) @options = options |