Module: Chef::Mixin::PowershellTypeCoercions
- Included in:
- Provider::DscResource
- Defined in:
- lib/chef/mixin/powershell_type_coercions.rb
Instance Method Summary collapse
Instance Method Details
#translate_type(value) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/chef/mixin/powershell_type_coercions.rb', line 35 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 |
#type_coercions ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/chef/mixin/powershell_type_coercions.rb', line 24 def type_coercions @type_coercions ||= { Fixnum => { :type => lambda { |x| x.to_s }}, Float => { :type => lambda { |x| x.to_s }}, FalseClass => { :type => lambda { |x| '$false' }}, TrueClass => { :type => lambda { |x| '$true' }}, Hash => {:type => Proc.new { |x| translate_hash(x)}}, Array => {:type => Proc.new { |x| translate_array(x)}} } end |