Class: WSDL::Parser::OperationMap Private

Inherits:
Object
  • Object
show all
Defined in:
lib/wsdl/parser/operation_map.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.

Stores operations by name, supporting WSDL 1.1 operation overloading.

Both PortType and Binding use this to store their operations. Consumers get clean single-operation lookups — overload handling is encapsulated. Operations must respond to #input_name for disambiguation when overloaded.

Examples:

Non-overloaded lookup

map.fetch('getBank')  # => PortTypeOperation

Overloaded lookup with disambiguation

map.fetch('Lookup', input_name: 'LookupById')  # => PortTypeOperation

Instance Method Summary collapse

Constructor Details

#initializeOperationMap

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 OperationMap.



20
21
22
# File 'lib/wsdl/parser/operation_map.rb', line 20

def initialize
  @entries = {}
end

Instance Method Details

#add(name, operation) ⇒ void

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.

This method returns an undefined value.

Adds an operation. Multiple operations with the same name are allowed per WSDL 1.1 §2.4.5 (operation overloading).

Parameters:

  • name (String)

    the operation name

  • operation (Object)

    the operation (must respond to #input_name)



30
31
32
# File 'lib/wsdl/parser/operation_map.rb', line 30

def add(name, operation)
  (@entries[name] ||= []) << operation
end

#fetch(name, input_name: nil) { ... } ⇒ 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.

Fetches a single operation by name.

For non-overloaded names, returns the operation directly. For overloaded names, uses input_name: to disambiguate. Raises ArgumentError if overloaded and no input_name is provided.

Parameters:

  • name (String)

    the operation name

  • input_name (String, Symbol, nil) (defaults to: nil)

    disambiguator for overloaded operations

Yields:

  • fallback when name is not found (like Hash#fetch)

Returns:

  • (Object)

    the matched operation

Raises:

  • (KeyError)

    if name is not found and no block given

  • (ArgumentError)

    if overloaded and disambiguation fails



61
62
63
64
65
66
67
# File 'lib/wsdl/parser/operation_map.rb', line 61

def fetch(name, input_name: nil, &not_found)
  ops = @entries.fetch(name, &not_found)
  return ops unless ops.is_a?(Array)
  return ops.first if ops.one?

  resolve_overload(name, input_name, ops)
end

#include?(name) ⇒ 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.

Whether a name exists in the map.

Parameters:

  • name (String)

Returns:

  • (Boolean)


45
46
47
# File 'lib/wsdl/parser/operation_map.rb', line 45

def include?(name)
  @entries.key?(name)
end

#keysArray<String>

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 unique operation names.

Returns:

  • (Array<String>)


37
38
39
# File 'lib/wsdl/parser/operation_map.rb', line 37

def keys
  @entries.keys
end

#overload_count(name) ⇒ Integer

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.

Number of definitions for a name.

Parameters:

  • name (String)

Returns:

  • (Integer)


82
83
84
# File 'lib/wsdl/parser/operation_map.rb', line 82

def overload_count(name)
  @entries[name]&.size || 0
end

#overloaded_name?(name) ⇒ 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.

Whether a specific name has multiple definitions.

Parameters:

  • name (String)

Returns:

  • (Boolean)


73
74
75
76
# File 'lib/wsdl/parser/operation_map.rb', line 73

def overloaded_name?(name)
  ops = @entries[name]
  !ops.nil? && ops.size > 1
end

#to_aArray<Hash>

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 an array of operation summary hashes.

Non-overloaded operations produce { name: "..." }. Overloaded operations include input_name for disambiguation.

Returns:

  • (Array<Hash>)


92
93
94
95
96
97
98
99
100
# File 'lib/wsdl/parser/operation_map.rb', line 92

def to_a
  @entries.flat_map do |name, ops|
    if ops.one?
      [{ name: }]
    else
      ops.map { |op| { name:, input_name: op.input_name } }
    end
  end
end