Class: ApiClient::Dispatcher::Parallel
- Inherits:
-
Object
- Object
- ApiClient::Dispatcher::Parallel
- Defined in:
- lib/api-client/dispatcher/parallel.rb
Overview
ApiClient::Dispatcher provides methods to make requests using typhoeus
Class Method Summary collapse
-
.delete(url, header = {}) ⇒ Typhoeus::Request
Make a delete request and returns it.
-
.get(url, header = {}) ⇒ Typhoeus::Request
Make a get request and returns it.
-
.patch(url, args, header = {}) ⇒ Typhoeus::Request
Make a patch request and returns it.
-
.post(url, args, header = {}) ⇒ Typhoeus::Request
Make a post request and returns it.
-
.put(url, args, header = {}) ⇒ Typhoeus::Request
Make a put request and returns it.
Instance Method Summary collapse
-
#initialize(requisition) ⇒ Parallel
constructor
Initialize a new object and save the request in a instance variable.
-
#on_complete_update(variable) ⇒ Object
When the requisition finish, this method update the given object with the response.
Constructor Details
#initialize(requisition) ⇒ Parallel
Initialize a new object and save the request in a instance variable.
6 7 8 |
# File 'lib/api-client/dispatcher/parallel.rb', line 6 def initialize(requisition) @requisition = requisition end |
Class Method Details
.delete(url, header = {}) ⇒ Typhoeus::Request
Make a delete request and returns it.
69 70 71 |
# File 'lib/api-client/dispatcher/parallel.rb', line 69 def self.delete(url, header = {}) new(::Typhoeus.Request.new(url, :method => :delete, :headers => ApiClient.config.header.merge(header))) end |
.get(url, header = {}) ⇒ Typhoeus::Request
Make a get request and returns it.
30 31 32 |
# File 'lib/api-client/dispatcher/parallel.rb', line 30 def self.get(url, header = {}) new(::Typhoeus::Request.new(url, :headers => ApiClient.config.header.merge(header))) end |
.patch(url, args, header = {}) ⇒ Typhoeus::Request
Make a patch request and returns it.
60 61 62 |
# File 'lib/api-client/dispatcher/parallel.rb', line 60 def self.patch(url, args, header = {}) new(::Typhoeus.Request.new(url, :method => :patch, :body => args, :headers => ApiClient.config.header.merge(header))) end |
.post(url, args, header = {}) ⇒ Typhoeus::Request
Make a post request and returns it.
40 41 42 |
# File 'lib/api-client/dispatcher/parallel.rb', line 40 def self.post(url, args, header = {}) new(::Typhoeus.Request.new(url, :method => :post, :body => args, :headers => ApiClient.config.header.merge(header))) end |
.put(url, args, header = {}) ⇒ Typhoeus::Request
Make a put request and returns it.
50 51 52 |
# File 'lib/api-client/dispatcher/parallel.rb', line 50 def self.put(url, args, header = {}) new(::Typhoeus.Request.new(url, :method => :put, :body => args, :headers => ApiClient.config.header.merge(header))) end |
Instance Method Details
#on_complete_update(variable) ⇒ Object
When the requisition finish, this method update the given object with the response.
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/api-client/dispatcher/parallel.rb', line 13 def on_complete_update(variable) @requisition.on_complete do |response| attributes = ApiClient::Parser.response(response, response.effective_url) if variable.instance_of?(ApiClient::Collection) variable.update(attributes) else variable.attributes = attributes end end ApiClient.config.hydra.queue @requisition end |