Module: Soaspec::ExchangeExtractor
- Included in:
- Exchange
- Defined in:
- lib/soaspec/exchange/exchange_extractor.rb
Overview
Methods for extracting aspects of the traffic for a request / response in an exchange from the ExchangeHandler that it’s tied to
Instance Method Summary collapse
-
#[](path) ⇒ String
(also: #value_from_path)
Extract value from path api class.
-
#element?(path) ⇒ Boolean
Using same path syntax as [].
-
#request ⇒ Object
Request of API call.
-
#status_code ⇒ Integer
Get status code from api class.
-
#to_hash ⇒ Hash
Return the response equivalent of the response.
-
#values_from_path(path, attribute: nil) ⇒ Array
List of values found at path.
Instance Method Details
#[](path) ⇒ String Also known as: value_from_path
Extract value from path api class
26 27 28 |
# File 'lib/soaspec/exchange/exchange_extractor.rb', line 26 def [](path) exchange_handler.value_from_path(response, path.to_s) end |
#element?(path) ⇒ Boolean
Using same path syntax as []. Returns true of false depending on whether an element is found
34 35 36 37 38 39 |
# File 'lib/soaspec/exchange/exchange_extractor.rb', line 34 def element?(path) self[path] true rescue NoElementAtPath false end |
#request ⇒ Object
Request of API call. Either intended request or actual request
7 8 9 |
# File 'lib/soaspec/exchange/exchange_extractor.rb', line 7 def request exchange_handler.request(@response) end |
#status_code ⇒ Integer
Get status code from api class. This is http response code for Web Api
13 14 15 |
# File 'lib/soaspec/exchange/exchange_extractor.rb', line 13 def status_code exchange_handler.status_code_for(response) end |
#to_hash ⇒ Hash
Return the response equivalent of the response. XML, JSON will be converted to a Hash
60 61 62 |
# File 'lib/soaspec/exchange/exchange_extractor.rb', line 60 def to_hash exchange_handler.to_hash(response) end |
#values_from_path(path, attribute: nil) ⇒ Array
Returns List of values found at path.
49 50 51 |
# File 'lib/soaspec/exchange/exchange_extractor.rb', line 49 def values_from_path(path, attribute: nil) exchange_handler.values_from_path(response, path, attribute: attribute) end |