Class: Array

Inherits:
Object show all
Defined in:
lib/savon/core_ext/array.rb

Instance Method Summary collapse

Instance Method Details

#to_soap_xml(key, escape_xml = true, attributes = {}) ⇒ Object

Translates the Array into SOAP compatible XML. See: Hash.to_soap_xml.



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/savon/core_ext/array.rb', line 4

def to_soap_xml(key, escape_xml = true, attributes = {})
  xml = Builder::XmlMarkup.new

  each_with_index do |item, index|
    attrs = tag_attributes attributes, index
    case item
      when Hash then xml.tag!(key, attrs) { xml << item.to_soap_xml }
      else           xml.tag!(key, attrs) { xml << (escape_xml ? item.to_soap_value : item.to_soap_value!) }
    end
  end

  xml.target!
end