Class: Soap::Parser::Binding
- Inherits:
-
Object
- Object
- Soap::Parser::Binding
- Defined in:
- lib/soap/parser/binding.rb
Constant Summary collapse
- COMPONENT_ATTRIBUTES =
%i[part parts message].freeze
Instance Attribute Summary collapse
-
#hash ⇒ Object
Returns the value of attribute hash.
-
#node ⇒ Object
readonly
Returns the value of attribute node.
Instance Method Summary collapse
-
#initialize(_namespaces, node) ⇒ Binding
constructor
A new instance of Binding.
- #parse ⇒ Object
- #parse_attribute(node) ⇒ Object
- #parse_binding ⇒ Object
- #parse_input_output(node, type) ⇒ Object
Constructor Details
#initialize(_namespaces, node) ⇒ Binding
Returns a new instance of Binding.
11 12 13 14 |
# File 'lib/soap/parser/binding.rb', line 11 def initialize(_namespaces, node) @node = node @hash = {} end |
Instance Attribute Details
#hash ⇒ Object
Returns the value of attribute hash.
8 9 10 |
# File 'lib/soap/parser/binding.rb', line 8 def hash @hash end |
#node ⇒ Object (readonly)
Returns the value of attribute node.
9 10 11 |
# File 'lib/soap/parser/binding.rb', line 9 def node @node end |
Instance Method Details
#parse ⇒ Object
16 17 18 |
# File 'lib/soap/parser/binding.rb', line 16 def parse parse_binding end |
#parse_attribute(node) ⇒ Object
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/soap/parser/binding.rb', line 43 def parse_attribute(node) attributes = COMPONENT_ATTRIBUTES.each.with_object({}) do |attr, attrs| value = node.attribute(attr.to_s) attrs[attr] = value.to_s if value end attributes[:name] = node.parent["name"] attributes end |
#parse_binding ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/soap/parser/binding.rb', line 20 def parse_binding return if @node.empty? && @node.first.nil? binding_node = @node.first @hash[:name] = binding_node["name"] @hash[:type] = binding_node["type"] operations = Hash[binding_node.xpath("./wsdl:operation").map do |operation| [operation["name"], { input: parse_input_output(operation, "input"), output: parse_input_output(operation, "output") }] end] @hash[:operations] = operations end |
#parse_input_output(node, type) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/soap/parser/binding.rb', line 35 def parse_input_output(node, type) type_node = node.element_children.find { |ec| ec.name == type } Hash[type_node.element_children.map do |elem| [elem.name, parse_attribute(elem)] end] end |