Class: QuestBack::Response
- Inherits:
-
Object
- Object
- QuestBack::Response
- Defined in:
- lib/quest_back/response.rb
Overview
Public: Simple proxy object decorating Savon’s response.
Main motication for class is to have #result and #results as a common interface to get to respons’ result(s), with all outer response nesting removed.
At the moment you are still getting back simple hashes from both methods.
Instance Attribute Summary collapse
-
#operation_name ⇒ Object
readonly
Returns the value of attribute operation_name.
-
#result_key_nestings ⇒ Object
readonly
Returns the value of attribute result_key_nestings.
-
#savon_response ⇒ Object
readonly
Returns the value of attribute savon_response.
Instance Method Summary collapse
-
#initialize(savon_response, options = {}) ⇒ Response
constructor
A new instance of Response.
- #result ⇒ Object
- #results ⇒ Object
Constructor Details
#initialize(savon_response, options = {}) ⇒ Response
Returns a new instance of Response.
14 15 16 17 18 |
# File 'lib/quest_back/response.rb', line 14 def initialize(savon_response, = {}) @savon_response = savon_response @operation_name = [:operation_name] or fail ArgumentError.new('Missing operation_name') @result_key_nestings = [:result_key_nestings] or fail ArgumentError.new('Missing result key nestings') end |
Instance Attribute Details
#operation_name ⇒ Object (readonly)
Returns the value of attribute operation_name.
10 11 12 |
# File 'lib/quest_back/response.rb', line 10 def operation_name @operation_name end |
#result_key_nestings ⇒ Object (readonly)
Returns the value of attribute result_key_nestings.
10 11 12 |
# File 'lib/quest_back/response.rb', line 10 def result_key_nestings @result_key_nestings end |
#savon_response ⇒ Object (readonly)
Returns the value of attribute savon_response.
10 11 12 |
# File 'lib/quest_back/response.rb', line 10 def savon_response @savon_response end |
Instance Method Details
#result ⇒ Object
20 21 22 23 24 |
# File 'lib/quest_back/response.rb', line 20 def result extract_result.tap do |result| fail QuestBack::Error::MultipleResultsFound if result.is_a? Array end end |
#results ⇒ Object
26 27 28 |
# File 'lib/quest_back/response.rb', line 26 def results Array.wrap extract_result end |