Class: Algolia::MultipleResponse
- Inherits:
-
BaseResponse
- Object
- BaseResponse
- Algolia::MultipleResponse
- Includes:
- Enumerable
- Defined in:
- lib/algolia/responses/multiple_response.rb
Instance Method Summary collapse
-
#each ⇒ Object
Iterates through the responses.
-
#initialize(responses = nil) ⇒ MultipleResponse
constructor
A new instance of MultipleResponse.
-
#last ⇒ Object
Fetch the last element of the responses.
-
#push(response) ⇒ Object
Add a new response to responses.
-
#wait(opts = {}) ⇒ Object
Wait for the task to complete.
Methods included from Helpers
#check_array, #check_object, #chunk, #deserialize_settings, #get_object_id, #get_option, #handle_params, #hash_includes_subset?, included, #json_to_hash, #path_encode, #symbolize_hash, #to_json, #to_query_string
Constructor Details
#initialize(responses = nil) ⇒ MultipleResponse
Returns a new instance of MultipleResponse.
7 8 9 |
# File 'lib/algolia/responses/multiple_response.rb', line 7 def initialize(responses = nil) @raw_responses = responses || [] end |
Instance Method Details
#each ⇒ Object
Iterates through the responses
39 40 41 42 43 |
# File 'lib/algolia/responses/multiple_response.rb', line 39 def each @raw_responses.each do |response| yield response end end |
#last ⇒ Object
Fetch the last element of the responses
13 14 15 |
# File 'lib/algolia/responses/multiple_response.rb', line 13 def last @raw_responses[@raw_responses.length - 1] end |
#push(response) ⇒ Object
Add a new response to responses
19 20 21 |
# File 'lib/algolia/responses/multiple_response.rb', line 19 def push(response) @raw_responses.push(response) end |
#wait(opts = {}) ⇒ Object
Wait for the task to complete
27 28 29 30 31 32 33 34 35 |
# File 'lib/algolia/responses/multiple_response.rb', line 27 def wait(opts = {}) @raw_responses.each do |response| response.wait(opts) end @raw_responses = [] self end |