Class Wrest::Components::Mutators::XmlSimpleTypeCaster

  1. lib/wrest/components/mutators/xml_simple_type_caster.rb
Parent: Mutators::Base

This mutator undertands how do type casting using the type data embedded in a hash created by deserialising an xml using xml-simple

Methods

public instance

  1. do_mutate

Public instance methods

do_mutate (tuple)
[show source]
    # File lib/wrest/components/mutators/xml_simple_type_caster.rb, line 17
17:       def do_mutate(tuple)
18:         out_key = tuple.first
19:         in_value = tuple.last[0]
20:         out_value = in_value
21: 
22:         case in_value
23:         when Hash
24:           if in_value['nil'] == 'true'
25:             out_value = nil
26:           elsif in_value.key?('type')
27:             out_value = ActiveSupport::XmlMini::PARSING[in_value['type']].call(in_value['content'])
28:           else
29:             out_value = in_value.mutate_using(self)
30:           end
31:         end
32: 
33:         [out_key, out_value]
34:       end