From c45107e4b0441ae6ce590a754880d8c33969ba20 Mon Sep 17 00:00:00 2001 From: Jay Mundrawala Date: Mon, 9 Mar 2015 22:08:03 -0700 Subject: Reorganize powershell_type_coercions --- lib/chef/mixin/powershell_type_coercions.rb | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'lib/chef/mixin/powershell_type_coercions.rb') 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 -- cgit v1.2.1