Class: Savon::GlobalOptions
- Includes:
- SharedOptions
- Defined in:
- lib/savon/options.rb
Instance Attribute Summary
Attributes inherited from Options
Instance Method Summary collapse
-
#adapter(adapter) ⇒ Object
Instruct Savon what Faraday adapter it should use instead of default.
-
#basic_auth(*credentials) ⇒ Object
HTTP basic auth credentials.
-
#convert_attributes_to(converter = nil, &block) ⇒ Object
Tell Nori how to convert XML attributes on tags from the SOAP response into Hash keys.
-
#convert_request_keys_to(converter) ⇒ Object
Tell Gyoku how to convert Hash key Symbols to XML tags.
-
#convert_response_tags_to(converter = nil, &block) ⇒ Object
Tell Nori how to convert XML tags from the SOAP response into Hash keys.
-
#delete_namespace_attributes(delete_namespace_attributes) ⇒ Object
Instruct Nori whether to delete namespace attributes from XML nodes.
-
#digest_auth(*credentials) ⇒ Object
HTTP digest auth credentials.
-
#element_form_default(element_form_default) ⇒ Object
Sets whether elements should be :qualified or :unqualified.
-
#encoding(encoding) ⇒ Object
The encoding to use.
-
#endpoint(endpoint) ⇒ Object
SOAP endpoint.
-
#env_namespace(env_namespace) ⇒ Object
Can be used to change the SOAP envelope namespace identifier.
-
#filters(*filters) ⇒ Object
A list of XML tags to filter from logged SOAP messages.
-
#follow_redirects(follow_redirects) ⇒ Object
Instruct requests to follow HTTP redirects.
-
#headers(headers) ⇒ Object
A Hash of HTTP headers.
-
#host(host) ⇒ Object
set different host for actions in WSDL.
-
#initialize(options = {}) ⇒ GlobalOptions
constructor
A new instance of GlobalOptions.
-
#log(log) ⇒ Object
Whether or not to log.
-
#log_headers(log_headers) ⇒ Object
To log headers or not.
-
#log_level(level) ⇒ Object
Changes the Logger's log level.
-
#logger(logger) ⇒ Object
The logger to use.
-
#multipart(multipart) ⇒ Object
Instruct Savon to create a multipart response if available.
-
#namespace(namespace) ⇒ Object
Target namespace.
-
#namespace_identifier(identifier) ⇒ Object
The namespace identifier.
-
#namespaces(namespaces) ⇒ Object
Namespaces for the SOAP envelope.
- #no_message_tag(bool) ⇒ Object
-
#ntlm(*credentials) ⇒ Object
NTLM auth credentials.
-
#open_timeout(open_timeout) ⇒ Object
Open timeout in seconds.
-
#pretty_print_xml(pretty_print_xml) ⇒ Object
Whether to pretty print request and response XML log messages.
-
#proxy(proxy) ⇒ Object
Proxy server to use for all requests.
-
#raise_errors(raise_errors) ⇒ Object
Whether or not to raise SOAP fault and HTTP errors.
-
#read_timeout(read_timeout) ⇒ Object
Read timeout in seconds.
-
#soap_header(header) ⇒ Object
The global SOAP header.
-
#soap_version(soap_version) ⇒ Object
Changes the SOAP version to 1 or 2.
-
#ssl_ca_cert(cert) ⇒ Object
Sets the ca cert to use.
-
#ssl_ca_cert_file(file) ⇒ Object
Sets the ca cert file to use.
-
#ssl_ca_cert_path(path) ⇒ Object
Sets the ca cert path.
-
#ssl_cert(cert) ⇒ Object
Sets the cert to use.
-
#ssl_cert_file(file) ⇒ Object
Sets the cert file to use.
-
#ssl_cert_key(key) ⇒ Object
Sets the cert key to use.
-
#ssl_cert_key_file(file) ⇒ Object
Sets the cert key file to use.
-
#ssl_cert_key_password(password) ⇒ Object
Sets the cert key password to use.
-
#ssl_cert_store(store) ⇒ Object
Sets the ssl cert store.
- #ssl_ciphers(ciphers) ⇒ Object
-
#ssl_max_version(version) ⇒ Object
Specifies the SSL version to use.
-
#ssl_min_version(version) ⇒ Object
Specifies the SSL version to use.
-
#ssl_verify_mode(verify_mode) ⇒ Object
Whether and how to to verify the connection.
-
#ssl_version(version) ⇒ Object
Specifies the SSL version to use.
-
#strip_namespaces(strip_namespaces) ⇒ Object
Instruct Nori whether to strip namespaces from XML nodes.
-
#unwrap(unwrap) ⇒ Object
Tell Gyoku to unwrap Array of Hashes Accepts a boolean, default to false.
-
#use_wsa_headers(use) ⇒ Object
Enable inclusion of WS-Addressing headers.
-
#write_timeout(write_timeout) ⇒ Object
Write timeout in seconds.
-
#wsdl(wsdl_address) ⇒ Object
Location of the local or remote WSDL document.
Methods included from SharedOptions
#wsse_auth, #wsse_signature, #wsse_timestamp
Methods inherited from Options
#[], #[]=, #deprecate, #include?
Constructor Details
#initialize(options = {}) ⇒ GlobalOptions
Returns a new instance of GlobalOptions.
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/savon/options.rb', line 76 def initialize( = {}) @option_type = :global defaults = { :encoding => "UTF-8", :soap_version => 1, :namespaces => {}, :logger => Logger.new($stdout), :log => false, :log_headers => true, :filters => [], :pretty_print_xml => false, :raise_errors => true, :strip_namespaces => true, :delete_namespace_attributes => false, :convert_response_tags_to => lambda { |tag| StringUtils.snakecase(tag).to_sym}, :convert_attributes_to => lambda { |k,v| [k,v] }, :multipart => false, :adapter => nil, :use_wsa_headers => false, :no_message_tag => false, :follow_redirects => false, :unwrap => false, :host => nil } = defaults.merge() # this option is a shortcut on the logger which needs to be set # before it can be modified to set the option. delayed_level = .delete(:log_level) super() log_level(delayed_level) unless delayed_level.nil? end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Savon::Options
Instance Method Details
#adapter(adapter) ⇒ Object
Instruct Savon what Faraday adapter it should use instead of default
371 372 373 |
# File 'lib/savon/options.rb', line 371 def adapter(adapter) @options[:adapter] = adapter end |
#basic_auth(*credentials) ⇒ Object
HTTP basic auth credentials.
314 315 316 |
# File 'lib/savon/options.rb', line 314 def basic_auth(*credentials) @options[:basic_auth] = credentials.flatten end |
#convert_attributes_to(converter = nil, &block) ⇒ Object
Tell Nori how to convert XML attributes on tags from the SOAP response into Hash keys. Accepts a lambda or a block which receives an XML tag and returns a Hash key. Defaults to doing nothing
361 362 363 |
# File 'lib/savon/options.rb', line 361 def convert_attributes_to(converter = nil, &block) @options[:convert_attributes_to] = block || converter end |
#convert_request_keys_to(converter) ⇒ Object
Tell Gyoku how to convert Hash key Symbols to XML tags. Accepts one of :lower_camelcase, :camelcase, :upcase, or :none.
341 342 343 |
# File 'lib/savon/options.rb', line 341 def convert_request_keys_to(converter) @options[:convert_request_keys_to] = converter end |
#convert_response_tags_to(converter = nil, &block) ⇒ Object
Tell Nori how to convert XML tags from the SOAP response into Hash keys. Accepts a lambda or a block which receives an XML tag and returns a Hash key. Defaults to convert tags to snakecase Symbols.
354 355 356 |
# File 'lib/savon/options.rb', line 354 def (converter = nil, &block) @options[:convert_response_tags_to] = block || converter end |
#delete_namespace_attributes(delete_namespace_attributes) ⇒ Object
Instruct Nori whether to delete namespace attributes from XML nodes.
335 336 337 |
# File 'lib/savon/options.rb', line 335 def delete_namespace_attributes(delete_namespace_attributes) @options[:delete_namespace_attributes] = delete_namespace_attributes end |
#digest_auth(*credentials) ⇒ Object
HTTP digest auth credentials.
319 320 321 322 |
# File 'lib/savon/options.rb', line 319 def digest_auth(*credentials) deprecate('digest_auth') @options[:digest_auth] = credentials.flatten end |
#element_form_default(element_form_default) ⇒ Object
Sets whether elements should be :qualified or :unqualified. If you need to use this option, please open an issue and make sure to add your WSDL document for debugging.
181 182 183 |
# File 'lib/savon/options.rb', line 181 def element_form_default(element_form_default) @options[:element_form_default] = element_form_default end |
#encoding(encoding) ⇒ Object
The encoding to use. Defaults to "UTF-8".
169 170 171 |
# File 'lib/savon/options.rb', line 169 def encoding(encoding) @options[:encoding] = encoding end |
#endpoint(endpoint) ⇒ Object
SOAP endpoint.
124 125 126 |
# File 'lib/savon/options.rb', line 124 def endpoint(endpoint) @options[:endpoint] = endpoint end |
#env_namespace(env_namespace) ⇒ Object
Can be used to change the SOAP envelope namespace identifier. If you need to use this option, please open an issue and make sure to add your WSDL document for debugging.
188 189 190 |
# File 'lib/savon/options.rb', line 188 def env_namespace(env_namespace) @options[:env_namespace] = env_namespace end |
#filters(*filters) ⇒ Object
A list of XML tags to filter from logged SOAP messages.
230 231 232 |
# File 'lib/savon/options.rb', line 230 def filters(*filters) @options[:filters] = filters.flatten end |
#follow_redirects(follow_redirects) ⇒ Object
Instruct requests to follow HTTP redirects.
385 386 387 |
# File 'lib/savon/options.rb', line 385 def follow_redirects(follow_redirects) @options[:follow_redirects] = follow_redirects end |
#headers(headers) ⇒ Object
A Hash of HTTP headers.
149 150 151 |
# File 'lib/savon/options.rb', line 149 def headers(headers) @options[:headers] = headers end |
#host(host) ⇒ Object
set different host for actions in WSDL
119 120 121 |
# File 'lib/savon/options.rb', line 119 def host(host) @options[:host] = host end |
#log(log) ⇒ Object
Whether or not to log.
203 204 205 |
# File 'lib/savon/options.rb', line 203 def log(log) @options[:log] = log end |
#log_headers(log_headers) ⇒ Object
To log headers or not.
225 226 227 |
# File 'lib/savon/options.rb', line 225 def log_headers(log_headers) @options[:log_headers] = log_headers end |
#log_level(level) ⇒ Object
Changes the Logger's log level.
213 214 215 216 217 218 219 220 221 222 |
# File 'lib/savon/options.rb', line 213 def log_level(level) levels = { :debug => 0, :info => 1, :warn => 2, :error => 3, :fatal => 4 } unless levels.include? level raise ArgumentError, "Invalid log level: #{level.inspect}\n" \ "Expected one of: #{levels.keys.inspect}" end @options[:logger].level = levels[level] end |
#logger(logger) ⇒ Object
The logger to use. Defaults to a Savon::Logger instance.
208 209 210 |
# File 'lib/savon/options.rb', line 208 def logger(logger) @options[:logger] = logger end |
#multipart(multipart) ⇒ Object
Instruct Savon to create a multipart response if available.
366 367 368 |
# File 'lib/savon/options.rb', line 366 def multipart(multipart) @options[:multipart] = multipart end |
#namespace(namespace) ⇒ Object
Target namespace.
129 130 131 |
# File 'lib/savon/options.rb', line 129 def namespace(namespace) @options[:namespace] = namespace end |
#namespace_identifier(identifier) ⇒ Object
The namespace identifier.
134 135 136 |
# File 'lib/savon/options.rb', line 134 def namespace_identifier(identifier) @options[:namespace_identifier] = identifier end |
#namespaces(namespaces) ⇒ Object
Namespaces for the SOAP envelope.
139 140 141 |
# File 'lib/savon/options.rb', line 139 def namespaces(namespaces) @options[:namespaces] = namespaces end |
#no_message_tag(bool) ⇒ Object
380 381 382 |
# File 'lib/savon/options.rb', line 380 def (bool) @options[:no_message_tag] = bool end |
#ntlm(*credentials) ⇒ Object
NTLM auth credentials.
325 326 327 |
# File 'lib/savon/options.rb', line 325 def ntlm(*credentials) @options[:ntlm] = credentials.flatten end |
#open_timeout(open_timeout) ⇒ Object
Open timeout in seconds.
154 155 156 |
# File 'lib/savon/options.rb', line 154 def open_timeout(open_timeout) @options[:open_timeout] = open_timeout end |
#pretty_print_xml(pretty_print_xml) ⇒ Object
Whether to pretty print request and response XML log messages.
235 236 237 |
# File 'lib/savon/options.rb', line 235 def pretty_print_xml(pretty_print_xml) @options[:pretty_print_xml] = pretty_print_xml end |
#proxy(proxy) ⇒ Object
Proxy server to use for all requests.
144 145 146 |
# File 'lib/savon/options.rb', line 144 def proxy(proxy) @options[:proxy] = proxy unless proxy.nil? end |
#raise_errors(raise_errors) ⇒ Object
Whether or not to raise SOAP fault and HTTP errors.
198 199 200 |
# File 'lib/savon/options.rb', line 198 def raise_errors(raise_errors) @options[:raise_errors] = raise_errors end |
#read_timeout(read_timeout) ⇒ Object
Read timeout in seconds.
159 160 161 |
# File 'lib/savon/options.rb', line 159 def read_timeout(read_timeout) @options[:read_timeout] = read_timeout end |
#soap_header(header) ⇒ Object
The global SOAP header. Expected to be a Hash or responding to #to_s.
174 175 176 |
# File 'lib/savon/options.rb', line 174 def soap_header(header) @options[:soap_header] = header end |
#soap_version(soap_version) ⇒ Object
Changes the SOAP version to 1 or 2.
193 194 195 |
# File 'lib/savon/options.rb', line 193 def soap_version(soap_version) @options[:soap_version] = soap_version end |
#ssl_ca_cert(cert) ⇒ Object
Sets the ca cert to use.
293 294 295 296 |
# File 'lib/savon/options.rb', line 293 def ssl_ca_cert(cert) deprecate('ssl_ca_cert') @options[:ssl_ca_cert] = cert end |
#ssl_ca_cert_file(file) ⇒ Object
Sets the ca cert file to use.
288 289 290 |
# File 'lib/savon/options.rb', line 288 def ssl_ca_cert_file(file) @options[:ssl_ca_cert_file] = file end |
#ssl_ca_cert_path(path) ⇒ Object
Sets the ca cert path.
304 305 306 |
# File 'lib/savon/options.rb', line 304 def ssl_ca_cert_path(path) @options[:ssl_ca_cert_path] = path end |
#ssl_cert(cert) ⇒ Object
Sets the cert to use.
283 284 285 |
# File 'lib/savon/options.rb', line 283 def ssl_cert(cert) @options[:ssl_cert] = cert end |
#ssl_cert_file(file) ⇒ Object
Sets the cert file to use.
277 278 279 280 |
# File 'lib/savon/options.rb', line 277 def ssl_cert_file(file) deprecate('ssl_cert_file') @options[:ssl_cert_file] = file end |
#ssl_cert_key(key) ⇒ Object
Sets the cert key to use.
266 267 268 |
# File 'lib/savon/options.rb', line 266 def ssl_cert_key(key) @options[:ssl_cert_key] = key end |
#ssl_cert_key_file(file) ⇒ Object
Sets the cert key file to use.
260 261 262 263 |
# File 'lib/savon/options.rb', line 260 def ssl_cert_key_file(file) deprecate('ssl_cert_key_file') @options[:ssl_cert_key_file] = file end |
#ssl_cert_key_password(password) ⇒ Object
Sets the cert key password to use.
271 272 273 274 |
# File 'lib/savon/options.rb', line 271 def ssl_cert_key_password(password) deprecate('ssl_cert_key_password') @options[:ssl_cert_key_password] = password end |
#ssl_cert_store(store) ⇒ Object
Sets the ssl cert store.
309 310 311 |
# File 'lib/savon/options.rb', line 309 def ssl_cert_store(store) @options[:ssl_cert_store] = store end |
#ssl_ciphers(ciphers) ⇒ Object
298 299 300 301 |
# File 'lib/savon/options.rb', line 298 def ssl_ciphers(ciphers) deprecate('ssl_ciphers') @options[:ssl_ciphers] = ciphers end |
#ssl_max_version(version) ⇒ Object
Specifies the SSL version to use.
250 251 252 |
# File 'lib/savon/options.rb', line 250 def ssl_max_version(version) @options[:ssl_max_version] = version end |
#ssl_min_version(version) ⇒ Object
Specifies the SSL version to use.
245 246 247 |
# File 'lib/savon/options.rb', line 245 def ssl_min_version(version) @options[:ssl_min_version] = version end |
#ssl_verify_mode(verify_mode) ⇒ Object
Whether and how to to verify the connection.
255 256 257 |
# File 'lib/savon/options.rb', line 255 def ssl_verify_mode(verify_mode) @options[:ssl_verify_mode] = verify_mode end |
#ssl_version(version) ⇒ Object
Specifies the SSL version to use.
240 241 242 |
# File 'lib/savon/options.rb', line 240 def ssl_version(version) @options[:ssl_version] = version end |
#strip_namespaces(strip_namespaces) ⇒ Object
Instruct Nori whether to strip namespaces from XML nodes.
330 331 332 |
# File 'lib/savon/options.rb', line 330 def strip_namespaces(strip_namespaces) @options[:strip_namespaces] = strip_namespaces end |
#unwrap(unwrap) ⇒ Object
Tell Gyoku to unwrap Array of Hashes Accepts a boolean, default to false
347 348 349 |
# File 'lib/savon/options.rb', line 347 def unwrap(unwrap) @options[:unwrap] = unwrap end |
#use_wsa_headers(use) ⇒ Object
Enable inclusion of WS-Addressing headers.
376 377 378 |
# File 'lib/savon/options.rb', line 376 def use_wsa_headers(use) @options[:use_wsa_headers] = use end |
#write_timeout(write_timeout) ⇒ Object
Write timeout in seconds.
164 165 166 |
# File 'lib/savon/options.rb', line 164 def write_timeout(write_timeout) @options[:write_timeout] = write_timeout end |
#wsdl(wsdl_address) ⇒ Object
Location of the local or remote WSDL document.
114 115 116 |
# File 'lib/savon/options.rb', line 114 def wsdl(wsdl_address) @options[:wsdl] = wsdl_address end |