Method: Parse::BatchOperation#submit

Defined in:
lib/parse/client/batch.rb

#submit(segment = 50) ⇒ Array<Parse::Response> Also known as: save

Submit the batch operation in chunks until they are all complete. In general, Parse limits requests in each batch to 50 and it is possible that a Parse::BatchOperation instance contains more than 50 requests. This method will slice up the array of request and send them based on the segment amount until they have all been submitted.

Parameters:

  • segment (Integer) (defaults to: 50)

    the number of requests to send in each batch. Default 50.

Returns:



130
131
132
133
134
135
136
137
138
139
140
# File 'lib/parse/client/batch.rb', line 130

def submit(segment = 50)
  @responses = []
  @requests.uniq!(&:signature)
  @responses = @requests.each_slice(segment).to_a.threaded_map(2) do |slice|
     client.batch_request( BatchOperation.new(slice) )
  end
  @responses.flatten!
  #puts "Requests: #{@requests.count} == Response: #{@responses.count}"
  @requests.zip(@responses).each(&Proc.new) if block_given?
  @responses
end