class Typhoeus::Hydra::EasyFactory

@api private
This is done by this class.
to be prepared and the on_complete callback to be set.
Before an easy is ready to be added to a multi, it needs
This is a Factory for easies to be used in the hydra.

def easy

Returns:
  • (Ethon::Easy) - The easy.

Other tags:
    Example: Return easy. -
def easy
  @easy ||= hydra.get_easy
end

def get

Returns:
  • (Ethon::Easy) - The prepared easy.

Other tags:
    Example: Prepared easy. -
def get
  easy.http_request(
    request.url,
    request.options.fetch(:method, :get),
    request.options.reject{|k,_| k==:method}
  )
  easy.prepare
  set_callback
  easy
end

def initialize(request, hydra)

Parameters:
  • hydra (Hydra) -- The hydra to build an easy for.
  • request (Request) -- The request to build an easy for.

Other tags:
    Example: Create easy factory. -
def initialize(request, hydra)
  @request = request
  @hydra = hydra
end

def set_callback

Returns:
  • (Ethon::Easy) - The easy.

Other tags:
    Example: Set callback. -
def set_callback
  easy.on_complete do |easy|
    request.finish(Response.new(easy.to_hash))
    hydra.release_easy(easy)
    hydra.queue(hydra.queued_requests.shift) unless hydra.queued_requests.empty?
  end
end