diff options
author | Jay Mundrawala <jdmundrawala@gmail.com> | 2015-03-09 22:08:03 -0700 |
---|---|---|
committer | Jay Mundrawala <jdmundrawala@gmail.com> | 2015-03-20 14:38:04 -0700 |
commit | c45107e4b0441ae6ce590a754880d8c33969ba20 (patch) | |
tree | 0fb6ece1ee3b3daec72f013bbed92c984ddf9cb4 | |
parent | 79655fae6724229704eb94781d55d658ad096815 (diff) | |
download | chef-c45107e4b0441ae6ce590a754880d8c33969ba20.tar.gz |
Reorganize powershell_type_coercions
-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 |