Class: WSDL::XML::Attribute Private

Inherits:
Object
  • Object
show all
Defined in:
lib/wsdl/xml/attribute.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Represents an XML attribute definition used for building SOAP messages.

Attributes are defined on complex type elements and can be either required or optional. They are rendered as XML attributes on the parent element rather than as child elements.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeAttribute

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Attribute.



14
15
16
# File 'lib/wsdl/xml/attribute.rb', line 14

def initialize
  @list = false
end

Instance Attribute Details

#base_typeString

The base type name for this attribute (e.g., 'xsd:string').

Returns:

  • (String)

    the base type name



26
27
28
# File 'lib/wsdl/xml/attribute.rb', line 26

def base_type
  @base_type
end

#listBoolean Also known as: list?

Whether this attribute is an xs:list type (whitespace-separated values).

Returns:

  • (Boolean)

    true for list-derived simple types



31
32
33
# File 'lib/wsdl/xml/attribute.rb', line 31

def list
  @list
end

#nameString

The local name of this attribute.

Returns:

  • (String)

    the attribute name



21
22
23
# File 'lib/wsdl/xml/attribute.rb', line 21

def name
  @name
end

#useString

The use constraint for this attribute ('optional' or 'required'). Defaults to 'optional' if not specified in the schema.

Returns:

  • (String)

    the use constraint



38
39
40
# File 'lib/wsdl/xml/attribute.rb', line 38

def use
  @use
end

Instance Method Details

#==(other) ⇒ Boolean Also known as: eql?

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Compares two attributes by their properties.

Parameters:

  • other (Object)

    the object to compare

Returns:

  • (Boolean)

    true if attributes have identical properties



82
83
84
85
86
87
88
89
# File 'lib/wsdl/xml/attribute.rb', line 82

def ==(other)
  return false unless other.is_a?(self.class)

  name == other.name &&
    base_type == other.base_type &&
    use == other.use &&
    list == other.list
end

#hashInteger

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns hash code based on attribute properties.

Returns:

  • (Integer)

    hash code based on attribute properties



94
95
96
# File 'lib/wsdl/xml/attribute.rb', line 94

def hash
  [name, base_type, use, list].hash
end

#optional?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns whether this attribute is optional.

Returns:

  • (Boolean)

    true if the attribute use is 'optional'



43
44
45
# File 'lib/wsdl/xml/attribute.rb', line 43

def optional?
  use == 'optional'
end

#to_definition_hHash{Symbol => Object}

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a definition-oriented hash representation.

This format preserves raw schema properties (base_type, use) rather than derived properties (type, required), making it suitable for serialization and round-trip reconstruction via Definition::ElementHash.

Returns:

  • (Hash{Symbol => Object})

    definition-compatible attribute hash



69
70
71
72
73
74
75
76
# File 'lib/wsdl/xml/attribute.rb', line 69

def to_definition_h
  {
    name:,
    base_type:,
    use:,
    list: list?
  }.freeze
end

#to_hHash{Symbol => Object}

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a hash representation of this attribute.

Used by both Element#to_a (for paths) and PartContract (for tree) to ensure consistent attribute metadata across introspection views.

Returns:

  • (Hash{Symbol => Object})

    attribute metadata



53
54
55
56
57
58
59
60
# File 'lib/wsdl/xml/attribute.rb', line 53

def to_h
  {
    name:,
    type: base_type,
    required: !optional?,
    list: list?
  }
end