Module: SmoothOperator::Operator::ClassMethods

Defined in:
lib/smooth_operator/operator.rb

Constant Summary collapse

OPTIONS =
{ endpoint: '', endpoint_user: '', endpoint_pass: '',
timeout: '', server_name: '', connection_options: {} }

Instance Method Summary collapse

Instance Method Details

#generate_parallel_connectionObject



95
96
97
# File 'lib/smooth_operator/operator.rb', line 95

def generate_parallel_connection
  Operators::Typhoeus.generate_parallel_connection
end

#headersObject



61
62
63
# File 'lib/smooth_operator/operator.rb', line 61

def headers
  get_option :headers, {}
end

#make_the_call(http_verb, relative_path = '', data = {}, options = {}) ⇒ Object



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/smooth_operator/operator.rb', line 65

def make_the_call(http_verb, relative_path = '', data = {}, options = {})
  options = HelperMethods.populate_options(self, options)

  resource_path = resource_path(relative_path, options)

  http_verb, resource_path, data, options = before_request(http_verb, resource_path, data, options)

  params, data = *HelperMethods.strip_params(self, http_verb, data)

  operator = HelperMethods.get_me_an_operator(options)

  operator.make_the_call(http_verb, resource_path, params, data, options) do |remote_call|
    block_given? ? yield(remote_call) : remote_call
  end
end

#query_string(params) ⇒ Object



81
82
83
# File 'lib/smooth_operator/operator.rb', line 81

def query_string(params)
  params
end

#resource_path(relative_path, options) ⇒ Object



85
86
87
88
89
90
91
92
93
# File 'lib/smooth_operator/operator.rb', line 85

def resource_path(relative_path, options)
  resources_name = options[:resources_name] || self.resources_name

  if Helpers.present?(resources_name)
    Helpers.present?(relative_path) ? "#{resources_name}/#{relative_path}" : resources_name
  else
    relative_path.to_s
  end
end