Class: WSDL::Contract::PartContract
- Inherits:
-
Object
- Object
- WSDL::Contract::PartContract
- Defined in:
- lib/wsdl/contract/part_contract.rb
Overview
Immutable contract for a request/response message part section.
Instance Attribute Summary collapse
-
#elements ⇒ Array<WSDL::XML::Element>
readonly
Returns the frozen collection of elements for this part.
Instance Method Summary collapse
-
#initialize(elements, section:) ⇒ PartContract
constructor
A new instance of PartContract.
-
#paths ⇒ Array<Hash{Symbol => Object}>
Flat path metadata for this part.
-
#template(mode: :minimal) ⇒ Template
Returns a request template helper.
-
#tree ⇒ Array<Hash{Symbol => Object}>
Hierarchical structure metadata for this part.
Constructor Details
#initialize(elements, section:) ⇒ PartContract
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
#elements ⇒ Array<WSDL::XML::Element> (readonly)
Returns the frozen collection of elements for this part.
The array itself is frozen; individual elements should be treated as read-only introspection objects.
21 22 23 |
# File 'lib/wsdl/contract/part_contract.rb', line 21 def elements @elements end |
Instance Method Details
#paths ⇒ Array<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.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/wsdl/contract/part_contract.rb', line 29 def paths @elements.flat_map(&:to_a).map do |path, data| { path: path, namespace: data[:namespace], form: data[:form], singular: data[:singular], min_occurs: data[:min_occurs], max_occurs: data[:max_occurs], type: data[:type], recursive_type: data[:recursive_type], attributes: data[:attributes], wildcard: data[:any_content] ? true : false }.compact end end |
#template(mode: :minimal) ⇒ Template
Returns a request template helper.
60 61 62 |
# File 'lib/wsdl/contract/part_contract.rb', line 60 def template(mode: :minimal) Template.new(section: @section, elements: @elements, mode:) end |
#tree ⇒ Array<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.
52 53 54 |
# File 'lib/wsdl/contract/part_contract.rb', line 52 def tree @elements.map { |element| element_tree(element) } end |