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
private
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
Returns a new instance of 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)
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.
19 20 21 |
# File 'lib/wsdl/contract/part_contract.rb', line 19 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.
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.
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 |