Class: Typhoeus::EasyFactory Private

Inherits:
Object
  • Object
show all
Defined in:
lib/typhoeus/easy_factory.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

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.

Since:

  • 0.5.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request, hydra = nil) ⇒ EasyFactory

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Create an easy factory.

Examples:

Create easy factory.

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

Since:

  • 0.5.0


28
29
30
31
# File 'lib/typhoeus/easy_factory.rb', line 28

def initialize(request, hydra = nil)
  @request = request
  @hydra = hydra
end

Instance Attribute Details

#hydraTyphoeus::Hydra (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the hydra provided.

Since:

  • 0.5.0


19
20
21
# File 'lib/typhoeus/easy_factory.rb', line 19

def hydra
  @hydra
end

#requestTyphoeus::Request (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the request provided.

Since:

  • 0.5.0


14
15
16
# File 'lib/typhoeus/easy_factory.rb', line 14

def request
  @request
end

Instance Method Details

#easyEthon::Easy

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return the easy in question.

Examples:

Return easy.

easy_factory.easy

Since:

  • 0.5.0


39
40
41
# File 'lib/typhoeus/easy_factory.rb', line 39

def easy
  @easy ||= Typhoeus::Pool.get
end

#getEthon::Easy

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Fabricated easy.

Examples:

Prepared easy.

easy_factory.get

Since:

  • 0.5.0


49
50
51
52
53
54
55
56
57
58
59
60
61
62
# 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