diff options
author | Giacomo Bagnoli <gbagnoli@gmail.com> | 2016-09-21 18:25:38 +0100 |
---|---|---|
committer | Giacomo Bagnoli <gbagnoli@gmail.com> | 2016-09-21 18:25:38 +0100 |
commit | 93cf29ce9b2baa072f13da1f0a509a6909998737 (patch) | |
tree | 94331c0f002884d38c092b2d678d7f4b00df61ed | |
parent | 39774946fbbd8b1f7d3267df3fcb7369ad5cac6d (diff) | |
download | chef-93cf29ce9b2baa072f13da1f0a509a6909998737.tar.gz |
Call convert_value in AttrArray constructor
-rw-r--r-- | lib/chef/node/attribute_collections.rb | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/lib/chef/node/attribute_collections.rb b/lib/chef/node/attribute_collections.rb index b36d4a1540..1bd31bceb0 100644 --- a/lib/chef/node/attribute_collections.rb +++ b/lib/chef/node/attribute_collections.rb @@ -73,6 +73,7 @@ class Chef def initialize(root, data) @root = root super(data) + map! { |e| convert_value(e) } end # For elements like Fixnums, true, nil... @@ -86,6 +87,23 @@ class Chef Array.new(map { |e| safe_dup(e) }) end + private + + def convert_value(value) + case value + when VividMash + value + when AttrArray + value + when Hash + VividMash.new(root, value) + when Array + AttrArray.new(root, value) + else + value + end + end + end # == VividMash @@ -184,10 +202,12 @@ class Chef case value when VividMash value + when AttrArray + value when Hash VividMash.new(root, value) when Array - AttrArray.new(root, value.map { |e| convert_value(e) }) + AttrArray.new(root, value) else value end |