Module: SmoothOperator::Operator

Included in:
Base
Defined in:
lib/smooth_operator/operator.rb

Constant Summary collapse

HTTP_VERBS =
[:get, :post, :put, :patch, :delete]
OPTIONS =
[:endpoint, :endpoint_user, :endpoint_pass, :timeout]

Instance Method Summary collapse

Instance Method Details

#generate_connection(adapter = nil, options = nil) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/smooth_operator/operator.rb', line 26

def generate_connection(adapter = nil, options = nil)
  adapter ||= :net_http
  options ||= {}
  url, timeout = (options[:endpoint] || self.endpoint), (options[:timeout] || self.timeout)

  Faraday.new(url: url) do |builder|
    builder.options.params_encoder = Faraday::NestedParamsEncoder # to properly encode arrays
    builder.options.timeout = timeout unless Helpers.blank?(timeout)
    builder.request :url_encoded
    builder.adapter adapter
  end
end

#generate_parallel_connectionObject



22
23
24
# File 'lib/smooth_operator/operator.rb', line 22

def generate_parallel_connection
  generate_connection(:typhoeus)
end