From e980fdb05780299a7d2ffe4215866eadc6d20a02 Mon Sep 17 00:00:00 2001 From: John Keiser Date: Wed, 25 Feb 2015 21:59:38 -0800 Subject: [PATCH] Allow node attributes to be used as input to new_json / augment_new_json (fixes chef/chef-provisioning#21) --- lib/cheffish/chef_provider_base.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/cheffish/chef_provider_base.rb b/lib/cheffish/chef_provider_base.rb index 8f46a8e..877e991 100644 --- a/lib/cheffish/chef_provider_base.rb +++ b/lib/cheffish/chef_provider_base.rb @@ -60,6 +60,9 @@ def resource_to_json(resource) json = resource.raw_json || {} keys.each do |json_key, resource_key| value = resource.send(resource_key) + # This takes care of Chef ImmutableMash and ImmutableArray + value = value.to_hash if value.is_a?(Hash) + value = value.to_a if value.is_a?(Array) json[json_key] = value if value end json