Class: Typhoeus::EasyFactory Private
- Inherits:
-
Object
- Object
- Typhoeus::EasyFactory
- 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.
Instance Attribute Summary collapse
-
#hydra ⇒ Typhoeus::Hydra
readonly
private
Returns the hydra provided.
-
#request ⇒ Typhoeus::Request
readonly
private
Returns the request provided.
Instance Method Summary collapse
-
#easy ⇒ Ethon::Easy
private
Return the easy in question.
-
#get ⇒ Ethon::Easy
private
Fabricated easy.
-
#initialize(request, hydra = nil) ⇒ EasyFactory
constructor
private
Create an easy factory.
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.
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
#hydra ⇒ Typhoeus::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.
19 20 21 |
# File 'lib/typhoeus/easy_factory.rb', line 19 def hydra @hydra end |
#request ⇒ Typhoeus::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.
14 15 16 |
# File 'lib/typhoeus/easy_factory.rb', line 14 def request @request end |
Instance Method Details
#easy ⇒ Ethon::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.
39 40 41 |
# File 'lib/typhoeus/easy_factory.rb', line 39 def easy @easy ||= Typhoeus::Pool.get end |
#get ⇒ Ethon::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.
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, request..fetch(:method, :get), request..reject{|k,_| k==:method} ) rescue Ethon::Errors::InvalidOption => e help = provide_help(e..match(/:\s(\w+)/)[1]) raise $!, "#{$!}#{help}", $!.backtrace end set_callback easy end |