summaryrefslogtreecommitdiff
path: root/lib/chef/mixin
diff options
context:
space:
mode:
authorJay Mundrawala <jdmundrawala@gmail.com>2015-03-04 20:28:07 -0800
committerJay Mundrawala <jdmundrawala@gmail.com>2015-03-20 14:38:04 -0700
commit4d3b0e6e37bfbc5e1e1c79621b7e311784bb6490 (patch)
tree80f9580e4f728b3011d34d1bf3e82b434ec755a6 /lib/chef/mixin
parentbf1acd692f204ccae18a0c236469beb56554e669 (diff)
downloadchef-4d3b0e6e37bfbc5e1e1c79621b7e311784bb6490.tar.gz
Added type coercsion for array
Diffstat (limited to 'lib/chef/mixin')
-rw-r--r--lib/chef/mixin/powershell_type_coercions.rb10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/chef/mixin/powershell_type_coercions.rb b/lib/chef/mixin/powershell_type_coercions.rb
index c5c035bb7c..1f216176c1 100644
--- a/lib/chef/mixin/powershell_type_coercions.rb
+++ b/lib/chef/mixin/powershell_type_coercions.rb
@@ -26,7 +26,8 @@ class Chef
Float => { :type => lambda { |x| x.to_s }, :single_quoted => false },
FalseClass => { :type => lambda { |x| '$false' }, :single_quoted => false },
TrueClass => { :type => lambda { |x| '$true' }, :single_quoted => false },
- Hash => {:type => Proc.new { |x| translate_hash(x)}, :single_quoted => false}
+ Hash => {:type => Proc.new { |x| translate_hash(x)}, :single_quoted => false},
+ Array => {:type => Proc.new { |x| translate_array(x)}, :single_quoted => false}
}
end
@@ -37,6 +38,13 @@ class Chef
"@{#{translated.join(';')}}"
end
+ def translate_array(x)
+ translated = x.map do |v|
+ translate_type(v)
+ end
+ "@(#{translated.join(',')})"
+ end
+
def translate_type(value)
translation = type_coercions[value.class]
translated_value = nil