Class: SalesforceBulk2::QueryResultCollection
- Inherits:
-
Array
- Object
- Array
- SalesforceBulk2::QueryResultCollection
- Defined in:
- lib/salesforce_bulk2/query_result_collection.rb
Instance Attribute Summary collapse
-
#batch_id ⇒ Object
readonly
Returns the value of attribute batch_id.
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#job_id ⇒ Object
readonly
Returns the value of attribute job_id.
-
#result_id ⇒ Object
readonly
Returns the value of attribute result_id.
-
#result_ids ⇒ Object
readonly
Returns the value of attribute result_ids.
Instance Method Summary collapse
-
#initialize(client, job_id, batch_id, result_id = nil, result_ids = []) ⇒ QueryResultCollection
constructor
A new instance of QueryResultCollection.
- #next ⇒ Object
- #next? ⇒ Boolean
- #previous ⇒ Object
- #previous? ⇒ Boolean
Constructor Details
#initialize(client, job_id, batch_id, result_id = nil, result_ids = []) ⇒ QueryResultCollection
Returns a new instance of QueryResultCollection.
10 11 12 13 14 15 16 17 |
# File 'lib/salesforce_bulk2/query_result_collection.rb', line 10 def initialize(client, job_id, batch_id, result_id=nil, result_ids=[]) @client = client @job_id = job_id @batch_id = batch_id @result_id = result_id @result_ids = result_ids @current_index = result_ids.index(result_id) || 0 end |
Instance Attribute Details
#batch_id ⇒ Object (readonly)
Returns the value of attribute batch_id.
5 6 7 |
# File 'lib/salesforce_bulk2/query_result_collection.rb', line 5 def batch_id @batch_id end |
#client ⇒ Object (readonly)
Returns the value of attribute client.
4 5 6 |
# File 'lib/salesforce_bulk2/query_result_collection.rb', line 4 def client @client end |
#job_id ⇒ Object (readonly)
Returns the value of attribute job_id.
6 7 8 |
# File 'lib/salesforce_bulk2/query_result_collection.rb', line 6 def job_id @job_id end |
#result_id ⇒ Object (readonly)
Returns the value of attribute result_id.
7 8 9 |
# File 'lib/salesforce_bulk2/query_result_collection.rb', line 7 def result_id @result_id end |
#result_ids ⇒ Object (readonly)
Returns the value of attribute result_ids.
8 9 10 |
# File 'lib/salesforce_bulk2/query_result_collection.rb', line 8 def result_ids @result_ids end |
Instance Method Details
#next ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/salesforce_bulk2/query_result_collection.rb', line 23 def next if next? replace(@client.query_result(job_id, batch_id, result_ids[@current_index + 1])) @current_index += 1 @result_id = @result_ids[@current_index] end self end |
#next? ⇒ Boolean
19 20 21 |
# File 'lib/salesforce_bulk2/query_result_collection.rb', line 19 def next? @result_ids.present? && @current_index < @result_ids.length - 1 end |
#previous ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/salesforce_bulk2/query_result_collection.rb', line 37 def previous if previous? replace(@client.query_result(job_id, batch_id, result_ids[@current_index - 1])) @current_index -= 1 @result_id = @result_ids[@current_index] end self end |
#previous? ⇒ Boolean
33 34 35 |
# File 'lib/salesforce_bulk2/query_result_collection.rb', line 33 def previous? @result_ids.present? && @current_index > 0 end |