Module: SmoothOperator::Operators::Typhoeus

Extended by:
Typhoeus
Included in:
Typhoeus
Defined in:
lib/smooth_operator/operators/typhoeus.rb

Instance Method Summary collapse

Instance Method Details

#make_the_call(http_verb, resource_path, params, body, options) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/smooth_operator/operators/typhoeus.rb', line 12

def make_the_call(http_verb, resource_path, params, body, options)
  request = ::Typhoeus::Request.new *typhoeus_request_args(http_verb, resource_path, params, body, options)
  
  hydra = options[:hydra] || ::Typhoeus::Hydra::hydra

  _remote_call = nil

  hydra.queue(request)

  request.on_complete do |typhoeus_response|          
    _remote_call = remote_call(typhoeus_response)

    yield(_remote_call) if block_given?
  end

  hydra.run if Helpers.blank?(options[:hydra])

  _remote_call
end