method

encode_attrs

Importance_0
Ruby latest stable (v2_5_5) - 0 notes - Class: SOAP::EncodingStyle::SOAPHandler

Method deprecated or moved

This method is deprecated or moved on the latest stable version. The last existing version (v1_8_7_330) is shown here.

encode_attrs(generator, ns, data, parent) private

No documentation

This method has no description. You can help the Ruby community by adding new notes.

Hide source
# File lib/soap/encodingstyle/soapHandler.rb, line 257
  def encode_attrs(generator, ns, data, parent)
    attrs = {}
    return attrs if data.is_a?(SOAPReference)

    if !parent || parent.encodingstyle != EncodingNamespace
      if @generate_explicit_type
        SOAPGenerator.assign_ns(attrs, ns, EnvelopeNamespace)
        attrs[ns.name(AttrEncodingStyleName)] = EncodingNamespace
      end
      data.encodingstyle = EncodingNamespace
    end

    if data.is_a?(SOAPNil)
      attrs[ns.name(XSD::AttrNilName)] = XSD::NilValue
    elsif @generate_explicit_type
      if data.type.namespace
        SOAPGenerator.assign_ns(attrs, ns, data.type.namespace)
      end
      if data.is_a?(SOAPArray)
        if data.arytype.namespace
          SOAPGenerator.assign_ns(attrs, ns, data.arytype.namespace)
        end
        SOAPGenerator.assign_ns(attrs, ns, EncodingNamespace)
        attrs[ns.name(AttrArrayTypeName)] = ns.name(create_arytype(ns, data))
        if data.type.name
          attrs[ns.name(XSD::AttrTypeName)] = ns.name(data.type)
        end
      elsif parent && parent.is_a?(SOAPArray) && (parent.arytype == data.type)
        # No need to add.
      elsif !data.type.namespace
        # No need to add.
      else
        attrs[ns.name(XSD::AttrTypeName)] = ns.name(data.type)
      end
    end

    data.extraattr.each do |key, value|
      SOAPGenerator.assign_ns(attrs, ns, key.namespace)
      attrs[ns.name(key)] = encode_attr_value(generator, ns, key, value)
    end
    if data.id
      attrs['id'] = data.id
    end
    attrs
  end
Register or log in to add new notes.