class ApiClient::Dispatcher::Parallel
ApiClient::Dispatcher provides methods to make requests using typhoeus
Public Class Methods
Make a delete request and returns it.
@param [String] url of the api request. @param [Hash] header attributes of the request. @return [Typhoeus::Request] the response object.
# 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
Make a get request and returns it.
@param [String] url of the api request. @param [Hash] header attributes of the request. @return [Typhoeus::Request] the response object.
# 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
Initialize a new object and save the request in a instance variable.
@param [Typhoeus::Request] requisition the requisition object.
# File lib/api-client/dispatcher/parallel.rb, line 6 def initialize(requisition) @requisition = requisition end
Make a patch request and returns it.
@param [String] url of the api request. @param [Hash] args attributes of object. @param [Hash] header attributes of the request. @return [Typhoeus::Request] the response object.
# 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
Make a post request and returns it.
@param [String] url of the api request. @param [Hash] args attributes of object. @param [Hash] header attributes of the request. @return [Typhoeus::Request] the response object.
# 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
Make a put request and returns it.
@param [String] url of the api request. @param [Hash] args attributes of object. @param [Hash] header attributes of the request. @return [Typhoeus::Request] the response object.
# 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
Public Instance Methods
When the requisition finish, this method update the given object with the response.
@param [ApiClient::Base, ApiClient::Collection] variable the object to update with the response.
# 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