Class: Faraday::Adapter::Typhoeus

Inherits:
Faraday::Adapter show all
Defined in:
lib/typhoeus/adapters/faraday.rb

Overview

Adapter to use Faraday with Typhoeus.

Examples:

Use Typhoeus.

require 'faraday'
require 'typhoeus'
require 'typhoeus/adapters/faraday'

conn = Faraday.new(url: "www.example.com") do |faraday|
  faraday.adapter :typhoeus

  # You can include Typhoeus options to be used for every request
  # faraday.adapter :typhoeus, forbid_reuse: true, maxredirs: 1
end

response = conn.get("/")

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app, adapter_options = {}) ⇒ void

Initialize the Typhoeus adapter

Parameters:

  • app (App)

    Farday app

  • [ (Hash)

    a customizable set of options



44
45
46
47
# File 'lib/typhoeus/adapters/faraday.rb', line 44

def initialize(app, adapter_options = {})
  super(app)
  @adapter_options = adapter_options
end

Class Method Details

.setup_parallel_manager(options = {}) ⇒ Typhoeus::Hydra

Setup Hydra with provided options.

Examples:

Setup Hydra.

Faraday::Adapter::Typhoeus.setup_parallel_manager
#=> #<Typhoeus::Hydra ... >

Returns:



59
60
61
# File 'lib/typhoeus/adapters/faraday.rb', line 59

def self.setup_parallel_manager(options = {})
  ::Typhoeus::Hydra.new(options)
end

Instance Method Details

#call(env) ⇒ void

This method returns an undefined value.

Hook into Faraday and perform the request with Typhoeus.

Parameters:

  • env (Hash)

    The environment.



70
71
72
73
74
# File 'lib/typhoeus/adapters/faraday.rb', line 70

def call(env)
  super
  perform_request env
  @app.call env
end