Module: Vindicia::XMLBuilder
- Included in:
- SoapClient, SoapObject
- Defined in:
- lib/vindicia.rb
Instance Method Summary collapse
- #build_array_xml(xml, name, type, value) ⇒ Object
- #build_tag_xml(xml, name, type, value) ⇒ Object
- #build_xml(xml, name, type, value) ⇒ Object
Instance Method Details
#build_array_xml(xml, name, type, value) ⇒ Object
149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/vindicia.rb', line 149 def build_array_xml(xml, name, type, value) attrs = { "xmlns:enc" => "http://schemas.xmlsoap.org/soap/encoding/", "xsi:type" => "enc:Array", "enc:arrayType" => "vin:#{name}[#{value.size}]" } xml.tag!(name, attrs) do |x| value.each do |val| build_tag_xml(x, 'item', type, val) end end end |
#build_tag_xml(xml, name, type, value) ⇒ Object
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
# File 'lib/vindicia.rb', line 162 def build_tag_xml(xml, name, type, value) case value when Hash Vindicia.class(type).new(value).build(xml, name) when SoapObject value.build(xml, name) when NilClass xml.tag!(name, value, {"xsi:nil" => true}) else type = type.sub(/^tns/,'vin') # format dates/times with full timestamp value = value.to_time.iso8601 if value.respond_to?(:to_time) && type == 'xsd:dateTime' xml.tag!(name, value, {"xsi:type" => type}) end end |
#build_xml(xml, name, type, value) ⇒ Object
141 142 143 144 145 146 147 |
# File 'lib/vindicia.rb', line 141 def build_xml(xml, name, type, value) if value.kind_of? Array build_array_xml(xml, name, type, value) else build_tag_xml(xml, name, type, value) end end |