Class: WSDL::Contract::PartContract

Inherits:
Object
  • Object
show all
Defined in:
lib/wsdl/contract/part_contract.rb

Overview

Immutable contract for a request/response message part section.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(elements, section:) ⇒ PartContract

Returns a new instance of PartContract.

Parameters:



9
10
11
12
13
# File 'lib/wsdl/contract/part_contract.rb', line 9

def initialize(elements, section:)
  @elements = elements.freeze
  @section = section
  freeze
end

Instance Attribute Details

#elementsArray<WSDL::XML::Element> (readonly)

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 the frozen collection of elements for this part.

Returns:



19
20
21
# File 'lib/wsdl/contract/part_contract.rb', line 19

def elements
  @elements
end

Instance Method Details

#pathsArray<Hash{Symbol => Object}>

Flat path metadata for this part.

Returns a fresh array of hashes on each call. Mutating the returned collection does not affect the contract's internal state.

Returns:

  • (Array<Hash{Symbol => Object}>)


27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/wsdl/contract/part_contract.rb', line 27

def paths
  @elements.flat_map(&:to_a).map do |path, data|
    {
      path:,
      kind: data[:kind],
      namespace: data[:namespace],
      form: data[:form],
      singular: data[:singular],
      min_occurs: data[:min_occurs],
      max_occurs: data[:max_occurs],
      type: data[:type],
      list: data[:list],
      recursive_type: data[:recursive_type],
      attributes: data[:attributes],
      wildcard: data[:any_content]
    }.compact
  end
end

#template(mode: :minimal) ⇒ Template

Returns a request template helper.

Parameters:

  • mode (Symbol) (defaults to: :minimal)

    :minimal or :full

Returns:



60
61
62
# File 'lib/wsdl/contract/part_contract.rb', line 60

def template(mode: :minimal)
  Template.new(section: @section, elements: @elements, mode:)
end

#treeArray<Hash{Symbol => Object}>

Hierarchical structure metadata for this part.

Returns a fresh array of hashes on each call. Mutating the returned collection does not affect the contract's internal state.

Returns:

  • (Array<Hash{Symbol => Object}>)


52
53
54
# File 'lib/wsdl/contract/part_contract.rb', line 52

def tree
  @elements.map { |element| element_tree(element) }
end