Class: Orchestrate::Application::Result
- Inherits:
-
Object
- Object
- Orchestrate::Application::Result
- Defined in:
- lib/orchestrate_application/result.rb
Overview
Packages the result data from GET requests. Orchestrate.io records are returned as Document objects.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#count ⇒ Object
readonly
Count of documents in #results.
-
#next ⇒ Object
readonly
Set for list results.
-
#response ⇒ Object
readonly
Upon success: the result data is extracted from the response body, but the response body itself is not inluded as part of the result.
-
#results ⇒ Object
readonly
Array of Document objects.
-
#status ⇒ Object
readonly
Boolean: return status of the api call.
Instance Method Summary collapse
-
#initialize(results) ⇒ Result
constructor
Initialize instance variables, based on type of results.
- #result ⇒ Object
- #result_keys ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(results) ⇒ Result
Initialize instance variables, based on type of results.
-
results (key/value)
-
results, count (events, graph)
-
results, count, next (list)
-
results, count, total_count (search)
31 32 33 |
# File 'lib/orchestrate_application/result.rb', line 31 def initialize(results) results.each { |k,v| instance_variable_set "@#{k}", v } end |
Instance Attribute Details
#count ⇒ Object (readonly)
Count of documents in #results. Set for list, search, events, and graph.
11 12 13 |
# File 'lib/orchestrate_application/result.rb', line 11 def count @count end |
#next ⇒ Object (readonly)
Set for list results.
14 15 16 |
# File 'lib/orchestrate_application/result.rb', line 14 def next @next end |
#response ⇒ Object (readonly)
Upon success: the result data is extracted from the response body, but the response body itself is not inluded as part of the result.
Upon failure: the original response body, Orchestrate::API::ResponseBody is left intact and included to provide access to the error details.
21 22 23 |
# File 'lib/orchestrate_application/result.rb', line 21 def response @response end |
#results ⇒ Object (readonly)
Array of Document objects.
8 9 10 |
# File 'lib/orchestrate_application/result.rb', line 8 def results @results end |
#status ⇒ Object (readonly)
Boolean: return status of the api call.
24 25 26 |
# File 'lib/orchestrate_application/result.rb', line 24 def status @status end |
Instance Method Details
#result ⇒ Object
35 36 37 |
# File 'lib/orchestrate_application/result.rb', line 35 def result results.first end |
#result_keys ⇒ Object
39 40 41 |
# File 'lib/orchestrate_application/result.rb', line 39 def result_keys results.map { |result| result..key } end |
#success? ⇒ Boolean
43 44 45 |
# File 'lib/orchestrate_application/result.rb', line 43 def success? status == true end |