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

Instance Method Details

#[](path) ⇒ String

Extract value from path api class



34
35
36
# File 'lib/soaspec/exchange/exchange_extractor.rb', line 34

def [](path)
  exchange_handler.value_from_path(response, path.to_s)
end

#element?(path) ⇒ Boolean



24
25
26
27
28
29
# File 'lib/soaspec/exchange/exchange_extractor.rb', line 24

def element?(path)
  self[path]
  true
rescue NoElementAtPath
  false
end

#methods_for_element(element) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/soaspec/exchange/exchange_extractor.rb', line 39

def methods_for_element(element)
  element_name = element.to_s.split('__custom_path_').last
  define_singleton_method(element_name) do
    exchange_handler.__send__(element, response) # Forward the call onto handler to retrieve the element for the response
  end
  define_singleton_method("#{element_name}?") do
    begin
      __send__ element_name
      true
    rescue NoElementAtPath
      false
    end
  end
end

#requestObject

Request of API call. Either intended request or actual request



13
14
15
# File 'lib/soaspec/exchange/exchange_extractor.rb', line 13

def request
  exchange_handler.request(@response)
end

#status_codeInteger

Get status code from api class. This is http response for Web Api



19
20
21
# File 'lib/soaspec/exchange/exchange_extractor.rb', line 19

def status_code
  exchange_handler.status_code_for(response)
end

#to_hashHash



55
56
57
# File 'lib/soaspec/exchange/exchange_extractor.rb', line 55

def to_hash
  exchange_handler.to_hash(response)
end

#values_from_path(path, attribute: nil) ⇒ Array



8
9
10
# File 'lib/soaspec/exchange/exchange_extractor.rb', line 8

def values_from_path(path, attribute: nil)
  exchange_handler.values_from_path(response, path, attribute: attribute)
end