Sha256: 30b0a3214426bff9a74260e88a0df68314d8a1c1b844a7f96c0270322af26353

Contents?: true

Size: 1.38 KB

Versions: 4

Compression:

Stored size: 1.38 KB

Contents

module WashOutHelper
  def wsdl_data(xml, params)
    params.each do |param|
      tag_name = "tns:#{param.name}"

      if !param.struct?
        if !param.multiplied
          xml.tag! tag_name, param.value, "xsi:type" => param.namespaced_type
        else
          param.value.each do |v|
            xml.tag! tag_name, v, "xsi:type" => param.namespaced_type
          end
        end
      else
        if !param.multiplied
          xml.tag! tag_name, "xsi:type" => param.namespaced_type do
            wsdl_data(xml, param.map)
          end
        else
          param.map.each do |p|
            xml.tag! tag_name, "xsi:type" => param.namespaced_type do
              wsdl_data(xml, p.map)
            end
          end
        end
      end
    end
  end

  def wsdl_type(xml, param)
    more = []

    if param.struct?
      xml.tag! "xsd:complexType", :name => param.name do
        xml.tag! "xsd:sequence" do
          param.map.each do |value|
            more << value if value.struct?
            xml.tag! "xsd:element", wsdl_occurence(value, :name => value.name, :type => value.namespaced_type)
          end
        end
      end
    end

    more.each do |p|
      wsdl_type xml, p
    end
  end

  def wsdl_occurence(param, extend_with = {})
    data = !param.multiplied ? {} : {
      "xsi:minOccurs" => 0,
      "xsi:maxOccurs" => 'unbounded'
    }

    extend_with.merge(data)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
wash_out-0.3.5 app/helpers/wash_out_helper.rb
wash_out-0.3.4 app/helpers/wash_out_helper.rb
wash_out-0.3.3 app/helpers/wash_out_helper.rb
wash_out-0.3.2 app/helpers/wash_out_helper.rb