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 Attribute Summary collapse
Instance Method Summary collapse
- #generate_connection(adapter = nil, options = nil) ⇒ Object
- #generate_parallel_connection ⇒ Object
- #make_the_call(http_verb, relative_path = '', data = {}, options = {}) ⇒ Object
Instance Attribute Details
#headers ⇒ Object
21 22 23 |
# File 'lib/smooth_operator/operator.rb', line 21 def headers Helpers.get_instance_variable(self, :headers, {}) end |
Instance Method Details
#generate_connection(adapter = nil, options = nil) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/smooth_operator/operator.rb', line 32 def generate_connection(adapter = nil, = nil) adapter ||= :net_http ||= {} url, timeout = ([:endpoint] || self.endpoint), ([:timeout] || self.timeout) ::Faraday.new(url: url) do |builder| builder.[:timeout] = timeout unless Helpers.blank?(timeout) builder.request :url_encoded builder.adapter adapter end end |
#generate_parallel_connection ⇒ Object
28 29 30 |
# File 'lib/smooth_operator/operator.rb', line 28 def generate_parallel_connection generate_connection(:typhoeus) end |
#make_the_call(http_verb, relative_path = '', data = {}, options = {}) ⇒ Object
44 45 46 47 48 49 50 51 52 |
# File 'lib/smooth_operator/operator.rb', line 44 def make_the_call(http_verb, relative_path = '', data = {}, = {}) if Helpers.present?([:hydra]) operator_call = OperatorCall::Faraday.new(self, http_verb, relative_path, data, ) else operator_call = OperatorCall::Typhoeus.new(self, http_verb, relative_path, data, ) end operator_call.make_the_call end |