class Parse::Batch
Attributes
client[R]
requests[R]
Public Class Methods
new(client = Parse.client)
click to toggle source
# File lib/parse/batch.rb, line 6 def initialize(client = Parse.client) @client = client @requests ||= [] end
Public Instance Methods
add_request(request)
click to toggle source
# File lib/parse/batch.rb, line 11 def add_request(request) @requests << request end
create_object(object)
click to toggle source
# File lib/parse/batch.rb, line 15 def create_object(object) method = "POST" path = Parse::Protocol.class_uri(object.class_name) body = object.safe_hash add_request({ "method" => method, "path" => path, "body" => body }) end
delete_object(object)
click to toggle source
# File lib/parse/batch.rb, line 37 def delete_object(object) add_request({ "method" => "DELETE", "path" => Parse::Protocol.class_uri(object.class_name, object.id) }) end
run!()
click to toggle source
# File lib/parse/batch.rb, line 44 def run! uri = Parse::Protocol.batch_request_uri body = {:requests => @requests}.to_json @client.request(uri, :post, body) end
update_object(object)
click to toggle source
# File lib/parse/batch.rb, line 26 def update_object(object) method = "PUT" path = Parse::Protocol.class_uri(object.class_name, object.id) body = object.safe_hash add_request({ "method" => method, "path" => path, "body" => body }) end