module Restool::Service::RemoteConnector

Public Class Methods

execute(remote_client, operation, path, params, headers, response_handler, representations, basic_auth) click to toggle source

The RemoteConnector module makes the requests using the RemoteClient, calls the response_handler with the response, and finally executes the object traversal

# File lib/restool/service/remote_connector.rb, line 10
def self.execute(remote_client, operation, path, params, headers,
                response_handler, representations, basic_auth)
  remote_response = remote_client.make_request(path, operation.method, params, headers,
                                               basic_auth)

  # Enumerable class does not have to_h in Ruby 1.9
  header = header_to_hash(remote_response.each_header)

  response = response_handler.call(remote_response.body, remote_response.code,
                                   header)

  return response if operation.response.nil?

  Restool::Traversal::Converter.convert(response, operation.response, representations)
end

Private Class Methods

header_to_hash(header) click to toggle source
# File lib/restool/service/remote_connector.rb, line 28
def self.header_to_hash(header)
  header.inject({}) do |memo, (key, value)|
    memo[key] = value
    memo
  end
end