diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/chef/mixin/powershell_type_coercions.rb | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/lib/chef/mixin/powershell_type_coercions.rb b/lib/chef/mixin/powershell_type_coercions.rb index 4bc0a098cb..75b3276c84 100644 --- a/lib/chef/mixin/powershell_type_coercions.rb +++ b/lib/chef/mixin/powershell_type_coercions.rb @@ -20,6 +20,7 @@ class Chef module Mixin module PowershellTypeCoercions + def type_coercions @type_coercions ||= { Fixnum => { :type => lambda { |x| x.to_s }}, @@ -31,6 +32,20 @@ class Chef } end + def translate_type(value) + translation = type_coercions[value.class] + + if translation + translation[:type].call(value) + elsif value.respond_to? :to_psobject + "(#{value.to_psobject})" + else + safe_string(value.to_s) + end + end + + private + def translate_hash(x) translated = x.inject([]) do |memo, (k,v)| memo << "#{k}=#{translate_type(v)}" @@ -62,19 +77,6 @@ class Chef "'#{s}'" end end - - def translate_type(value) - translation = type_coercions[value.class] - - if translation - translation[:type].call(value) - elsif value.respond_to? :to_psobject - "(#{value.to_psobject})" - else - safe_string(value.to_s) - end - end - end end end |