Class: Parse::BatchHttpClient
- Inherits:
-
HttpClient
- Object
- HttpClient
- Parse::BatchHttpClient
- Defined in:
- lib/parse/batch_http_client.rb
Instance Attribute Summary collapse
-
#after_blocks ⇒ Object
Returns the value of attribute after_blocks.
-
#requests ⇒ Object
Returns the value of attribute requests.
Attributes inherited from HttpClient
Instance Method Summary collapse
-
#initialize(host) ⇒ BatchHttpClient
constructor
A new instance of BatchHttpClient.
- #request(method, endpoint, headers = {}, body = nil, &block) ⇒ Object
Constructor Details
#initialize(host) ⇒ BatchHttpClient
Returns a new instance of BatchHttpClient.
5 6 7 8 9 |
# File 'lib/parse/batch_http_client.rb', line 5 def initialize host @host = host @requests = [] @after_blocks = [] end |
Instance Attribute Details
#after_blocks ⇒ Object
Returns the value of attribute after_blocks.
3 4 5 |
# File 'lib/parse/batch_http_client.rb', line 3 def after_blocks @after_blocks end |
#requests ⇒ Object
Returns the value of attribute requests.
3 4 5 |
# File 'lib/parse/batch_http_client.rb', line 3 def requests @requests end |
Instance Method Details
#request(method, endpoint, headers = {}, body = nil, &block) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/parse/batch_http_client.rb', line 11 def request method, endpoint, headers={}, body=nil, &block raise 'find cannot be in a batch request.' if method.to_s.upcase == 'GET' @after_blocks << block @requests << { "method" => method.to_s.upcase, "path" => endpoint, "body" => JSON.parse(body) # TODO: ?? } end |