Parent

Methods

Typhoeus::EasyFactory

This is a Factory for easies to be used in the hydra. Before an easy is ready to be added to a multi the on_complete callback to be set. This is done by this class.

@api private

Attributes

hydra[R]

Returns the hydra provided.

@return [ Typhoeus::Hydra ]

request[R]

Returns the request provided.

@return [ Typhoeus::Request ]

Public Class Methods

new(request, hydra = nil) click to toggle source

Create an easy factory.

@example Create easy factory.

Typhoeus::Hydra::EasyFactory.new(request, hydra)

@param [ Request ] request The request to build an easy for. @param [ Hydra ] hydra The hydra to build an easy for.

# File lib/typhoeus/easy_factory.rb, line 28
def initialize(request, hydra = nil)
  @request = request
  @hydra = hydra
end

Public Instance Methods

easy() click to toggle source

Return the easy in question.

@example Return easy.

easy_factory.easy

@return [ Ethon::Easy ] The easy.

# File lib/typhoeus/easy_factory.rb, line 39
def easy
  @easy ||= Typhoeus::Pool.get
end
get() click to toggle source

Fabricated easy.

@example Prepared easy.

easy_factory.get

@return [ Ethon::Easy ] The easy.

# File lib/typhoeus/easy_factory.rb, line 49
def get
  begin
    easy.http_request(
      request.base_url.to_s,
      request.options.fetch(:method, :get),
      sanitize(request.options)
    )
  rescue Ethon::Errors::InvalidOption => e
    help = provide_help(e.message.match(/:\s(\w+)/)[1])
    raise $!, "#{$!}#{help}", $!.backtrace
  end
  set_callback
  easy
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.