module SmoothOperator::Operator

Public Class Methods

included(base) click to toggle source
# File lib/smooth_operator/operator.rb, line 42
def self.included(base)
  base.extend(ClassMethods)
end

Public Instance Methods

headers() click to toggle source
# File lib/smooth_operator/operator.rb, line 11
def headers
  {}
end
make_the_call(http_verb, relative_path = '', data = {}, options = {}) { |remote_call| ... } click to toggle source
# File lib/smooth_operator/operator.rb, line 15
def make_the_call(http_verb, relative_path = '', data = {}, options = {})
  options ||= {}

  relative_path = resource_path(relative_path)

  options[:headers]         = headers.merge(options[:headers] || {})
  options[:parent_object] ||= _options[:parent_object]

  call_args = before_request(http_verb, relative_path, data, options)

  self.class.make_the_call(*call_args) do |remote_call|
    yield(remote_call)
  end
end
resource_path(relative_path) click to toggle source
# File lib/smooth_operator/operator.rb, line 30
def resource_path(relative_path)
  if Helpers.absolute_path?(relative_path)
    Helpers.remove_initial_slash(relative_path)
  elsif persisted?
    id = Helpers.primary_key(self)

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