Class: AdsCommon::ResultsExtractor

Inherits:
Object
  • Object
show all
Defined in:
lib/ads_common/results_extractor.rb

Instance Method Summary collapse

Constructor Details

#initialize(registry) ⇒ ResultsExtractor

Instance initializer.

Args:

- registry: a registry that defines service


28
29
30
# File 'lib/ads_common/results_extractor.rb', line 28

def initialize(registry)
  @registry = registry
end

Instance Method Details

#extract_exception_data(soap_fault, exception_name) ⇒ Object

Extracts misc data from SOAP fault.



53
54
55
56
57
58
# File 'lib/ads_common/results_extractor.rb', line 53

def extract_exception_data(soap_fault, exception_name)
  exception_type = get_full_type_signature(exception_name)
  process_attributes(soap_fault, false)
  soap_fault = normalize_fields(soap_fault, exception_type[:fields])
  return soap_fault
end

#extract_header_data(response) ⇒ Object

Extracts misc data from response header.



44
45
46
47
48
49
50
# File 'lib/ads_common/results_extractor.rb', line 44

def extract_header_data(response)
  header_type = get_full_type_signature(:SoapResponseHeader)
  headers = response.header[:response_header].dup
  process_attributes(headers, false)
  headers = normalize_fields(headers, header_type[:fields])
  return headers
end

#extract_result(response, action_name) ⇒ Object

Extracts the finest results possible for the given result. Returns the response itself in worst case (contents unknown).



34
35
36
37
38
39
40
41
# File 'lib/ads_common/results_extractor.rb', line 34

def extract_result(response, action_name)
  method = @registry.get_method_signature(action_name)
  action = method[:output][:name].to_sym
  result = response.to_hash
  result = result[action] if result.include?(action)
  result = normalize_output(result, method)
  return result[:rval] || result
end