Class: Savon::EffectiveOptions
- Inherits:
-
Object
- Object
- Savon::EffectiveOptions
- Defined in:
- lib/savon/effective_options.rb
Overview
Resolves the effective value of options whose answer combines more than one source: the per-request options, the client options, the WSDL document, and built-in defaults.
GlobalOptions and LocalOptions store what the caller said. EffectiveOptions answers what the request uses. It owns the precedence rules and exposes one reader per resolvable option, so every consumer of an option resolves it identically. Resolution is a pure read. It never mutates the options or the WSDL document.
Instance Method Summary collapse
-
#endpoint ⇒ URI, ...
Resolves the endpoint URL the request is sent to.
-
#initialize(operation_name, wsdl, globals, locals) ⇒ EffectiveOptions
constructor
A new instance of EffectiveOptions.
-
#soap_action ⇒ String?
Resolves the SOAPAction of the request (SOAP 1.1 §6.1.1).
-
#soap_header ⇒ Hash, ...
Resolves the SOAP header content.
-
#wsse_auth ⇒ Array<String>, ...
Resolves the WSSE auth credentials passed to Akami.
-
#wsse_signature ⇒ Akami::WSSE::Signature?
Resolves the WSSE signature used to sign the request.
-
#wsse_timestamp ⇒ Boolean?
Resolves whether Akami emits a
wsu:Timestampheader, using the same local-over-global rule as #wsse_auth.
Constructor Details
#initialize(operation_name, wsdl, globals, locals) ⇒ EffectiveOptions
Returns a new instance of EffectiveOptions.
22 23 24 25 26 27 |
# File 'lib/savon/effective_options.rb', line 22 def initialize(operation_name, wsdl, globals, locals) @operation_name = operation_name @wsdl = wsdl @globals = globals @locals = locals end |
Instance Method Details
#endpoint ⇒ URI, ...
Resolves the endpoint URL the request is sent to.
A global :endpoint wins over the service address of the WSDL. The
global :host option replaces host and port of the WSDL address and
keeps scheme, path and query. The override is applied to a copy. The
WSDL document keeps its parsed address.
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/savon/effective_options.rb', line 54 def endpoint return @globals[:endpoint] if @globals[:endpoint] return @wsdl.endpoint unless @globals[:host] host_url = URI.parse(@globals[:host]) url = @wsdl.endpoint.dup url.host = host_url.host url.port = host_url.port url end |
#soap_action ⇒ String?
Resolves the SOAPAction of the request (SOAP 1.1 §6.1.1).
An explicit local :soap_action wins. A local false or nil disables
the action, so no SOAPAction HTTP header is sent and an enabled
wsa:Action header stays empty. Without a local value the WSDL provides
the soapAction of the operation. Without a WSDL document the operation
name is converted to an XML tag as a best-effort default.
38 39 40 41 42 43 44 |
# File 'lib/savon/effective_options.rb', line 38 def soap_action return if @locals.include?(:soap_action) && !@locals[:soap_action] @locals[:soap_action] || (@wsdl.document? && @wsdl.soap_action(@operation_name.to_sym)) || Gyoku.xml_tag(@operation_name, key_converter: @globals[:convert_request_keys_to]) end |
#soap_header ⇒ Hash, ...
Resolves the SOAP header content. When both scopes provide a Hash the two
are merged and local keys win. Otherwise the local value is preferred and
falls back to the global one. A Hash is rendered to XML by Gyoku. A String,
or any object responding to #to_s, is used verbatim.
101 102 103 104 105 106 107 108 109 110 |
# File 'lib/savon/effective_options.rb', line 101 def soap_header global = @globals[:soap_header] local = @locals[:soap_header] if global.is_a?(Hash) && local.is_a?(Hash) global.merge(local) else local || global end end |
#wsse_auth ⇒ Array<String>, ...
Resolves the WSSE auth credentials passed to Akami. A local value takes
precedence over the global one. A local false disables auth even when a
global value is set. A local nil leaves the option unset and falls
through to the global value.
72 73 74 |
# File 'lib/savon/effective_options.rb', line 72 def wsse_auth prefer_local(:wsse_auth) end |
#wsse_signature ⇒ Akami::WSSE::Signature?
91 92 93 |
# File 'lib/savon/effective_options.rb', line 91 def wsse_signature @locals[:wsse_signature] || @globals[:wsse_signature] end |
#wsse_timestamp ⇒ Boolean?
Resolves whether Akami emits a wsu:Timestamp header, using the same
local-over-global rule as #wsse_auth. A local false disables it and a
local nil keeps the global value.
81 82 83 |
# File 'lib/savon/effective_options.rb', line 81 def prefer_local(:wsse_timestamp) end |