Class: Parse::Batch
- Inherits:
-
Object
- Object
- Parse::Batch
- Defined in:
- lib/parse/batch.rb
Instance Attribute Summary collapse
-
#requests ⇒ Object
readonly
Returns the value of attribute requests.
Instance Method Summary collapse
- #add_request(request) ⇒ Object
- #create_object(object) ⇒ Object
- #delete_object(object) ⇒ Object
-
#initialize ⇒ Batch
constructor
A new instance of Batch.
- #run! ⇒ Object
- #update_object(object) ⇒ Object
Constructor Details
#initialize ⇒ Batch
Returns a new instance of Batch.
7 8 9 |
# File 'lib/parse/batch.rb', line 7 def initialize @requests ||= [] end |
Instance Attribute Details
#requests ⇒ Object (readonly)
Returns the value of attribute requests.
5 6 7 |
# File 'lib/parse/batch.rb', line 5 def requests @requests end |
Instance Method Details
#add_request(request) ⇒ Object
11 12 13 |
# File 'lib/parse/batch.rb', line 11 def add_request(request) @requests << request end |
#create_object(object) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# 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) ⇒ Object
37 38 39 40 41 42 |
# 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 |