Class: Orchestrate::Application::Result

Inherits:
Object
  • Object
show all
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

SearchResult

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#countObject (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

#nextObject (readonly)

Set for list results.



14
15
16
# File 'lib/orchestrate_application/result.rb', line 14

def next
  @next
end

#responseObject (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

#resultsObject (readonly)

Array of Document objects.



8
9
10
# File 'lib/orchestrate_application/result.rb', line 8

def results
  @results
end

#statusObject (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

#resultObject



35
36
37
# File 'lib/orchestrate_application/result.rb', line 35

def result
	results.first
end

#result_keysObject



39
40
41
# File 'lib/orchestrate_application/result.rb', line 39

def result_keys
  results.map { |result| result..key }
end

#success?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/orchestrate_application/result.rb', line 43

def success?
  status == true
end