Class: SalesforceBulk2::QueryResultCollection

Inherits:
Array
  • Object
show all
Defined in:
lib/salesforce_bulk2/query_result_collection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_idObject (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

#clientObject (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_idObject (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_idObject (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_idsObject (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

#nextObject



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

Returns:

  • (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

#previousObject



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

Returns:

  • (Boolean)


33
34
35
# File 'lib/salesforce_bulk2/query_result_collection.rb', line 33

def previous?
  @result_ids.present? && @current_index > 0
end