diff options
author | Noah Kantrowitz <noah@coderanger.net> | 2017-04-04 00:19:41 -0700 |
---|---|---|
committer | Noah Kantrowitz <noah@coderanger.net> | 2017-04-04 00:19:41 -0700 |
commit | dbb339175b445bcd4dfd6c54bababf9dd7908993 (patch) | |
tree | cb3b3f7762d0fb9916946c77d25471ce96dca694 /lib | |
parent | e77023bdce2db2522f0320237c532e6c6eaa93a2 (diff) | |
download | chef-dbb339175b445bcd4dfd6c54bababf9dd7908993.tar.gz |
Cope with the common case of passing node[“whatever”] as template variables.
Signed-off-by: Noah Kantrowitz <noah@coderanger.net>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/chef/provider/template/content.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/chef/provider/template/content.rb b/lib/chef/provider/template/content.rb index 76a3e6d169..b40794564a 100644 --- a/lib/chef/provider/template/content.rb +++ b/lib/chef/provider/template/content.rb @@ -40,8 +40,12 @@ class Chef visitor = lambda do |obj| case obj when Hash + # If this is an Attribute object, we need to change class otherwise + # we get the immutable behavior. This could probably be fixed by + # using Hash#transform_values once we only support Ruby 2.4. + obj_class = obj.is_a?(Chef::Node::ImmutableMash) ? Mash : obj.class # Avoid mutating hashes in the resource in case we're changing anything. - obj.each_with_object(obj.class.new) do |(key, value), memo| + obj.each_with_object(obj_class.new) do |(key, value), memo| memo[key] = visitor.call(value) end when Array |