Class: Typhoeus::Hydra::EasyFactory Private

Inherits:
Object
  • Object
show all
Defined in:
lib/typhoeus/hydra/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) ⇒ 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)

Parameters:

  • request (Request)

    The request to build an easy for.

  • hydra (Hydra)

    The hydra to build an easy for.

Since:

  • 0.5.0



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

def initialize(request, hydra)
  @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.

Returns:

Since:

  • 0.5.0



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

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.

Returns:

Since:

  • 0.5.0



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

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

Returns:

  • (Ethon::Easy)

    The easy.

Since:

  • 0.5.0



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

def easy
  @easy ||= hydra.get_easy
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

Returns:

  • (Ethon::Easy)

    The easy.

Since:

  • 0.5.0



50
51
52
53
54
55
56
57
58
# File 'lib/typhoeus/hydra/easy_factory.rb', line 50

def get
  easy.http_request(
    request.base_url,
    request.options.fetch(:method, :get),
    request.options.reject{|k,_| k==:method}
  )
  set_callback
  easy
end