Module: SmoothOperator::Operators::Typhoeus
Instance Method Summary collapse
- #generate_connection(adapter = nil, options = nil) ⇒ Object
- #generate_parallel_connection ⇒ Object
- #make_the_call(http_verb, resource_path, params, body, options) ⇒ Object
Instance Method Details
#generate_connection(adapter = nil, options = nil) ⇒ Object
16 17 18 |
# File 'lib/smooth_operator/operators/typhoeus.rb', line 16 def generate_connection(adapter = nil, = nil) ConnectionWrapper.new(::Typhoeus::Hydra::hydra) end |
#generate_parallel_connection ⇒ Object
12 13 14 |
# File 'lib/smooth_operator/operators/typhoeus.rb', line 12 def generate_parallel_connection generate_connection end |
#make_the_call(http_verb, resource_path, params, body, options) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/smooth_operator/operators/typhoeus.rb', line 20 def make_the_call(http_verb, resource_path, params, body, ) request = ::Typhoeus::Request.new *typhoeus_request_args(http_verb, resource_path, params, body, ) hydra = ([:connection] || generate_connection).connection request_result = nil hydra.queue(request) request.on_complete do |typhoeus_response| remote_call = remote_call(typhoeus_response) if block_given? request_result = yield(remote_call) else request_result = remote_call end end hydra.run if Helpers.blank?([:connection]) request_result end |