diff options
Diffstat (limited to 'lib/chef/provider')
-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 |