Class: SmoothOperator::Operators::Typhoeus

Inherits:
Base
  • Object
show all
Defined in:
lib/smooth_operator/operators/typhoeus.rb

Instance Attribute Summary

Attributes inherited from Base

#body, #connection, #endpoint_pass, #endpoint_user, #http_verb, #operator_class, #operator_options, #options, #params, #relative_path

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from SmoothOperator::Operators::Base

Instance Method Details

#make_the_callObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/smooth_operator/operators/typhoeus.rb', line 10

def make_the_call
  set_basic_authentication

  request = ::Typhoeus::Request.new(url, typhoeus_options)
  
  remote_call = {}

  # hydra.queue(request)

  request.on_complete do |typhoeus_response|
    remote_call_class = if typhoeus_response.return_code == :couldnt_connect
      RemoteCall::Errors::ConnectionFailed
    elsif typhoeus_response.timed_out?
      RemoteCall::Errors::Timeout
    else
      RemoteCall::Typhoeus
    end
    
    remote_call = remote_call_class.new(typhoeus_response)

    yield(remote_call) if block_given?
  end

  # hydra.run

  request.run

  remote_call
end