Class: Wrest::Components::Mutators::XmlSimpleTypeCaster
- Defined in:
- lib/wrest/components/mutators/xml_simple_type_caster.rb
Overview
This mutator undertands how do type casting using the type data embedded in a hash created by deserialising an xml using xml-simple
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
inherited, #initialize, #mutate
Constructor Details
This class inherits a constructor from Wrest::Components::Mutators::Base
Instance Method Details
#do_mutate(tuple) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/wrest/components/mutators/xml_simple_type_caster.rb', line 17 def do_mutate(tuple) out_key = tuple.first in_value = tuple.last[0] out_value = in_value case in_value when Hash if in_value['nil'] == 'true' out_value = nil elsif in_value.key?('type') out_value = ActiveSupport::CoreExtensions::Hash::Conversions::XML_PARSING[in_value['type']].call(in_value['content']) else out_value = in_value.mutate_using(self) end end [out_key, out_value] end |