module Skynet::Accessor

Public Class Methods

query(client, path_info, args = {}) click to toggle source
# File lib/skynet/accessor.rb, line 5
def self.query(client, path_info, args = {})
  @client = client
  @conn = set_up_faraday

  client_args = args.merge({ access_code: @client.access_code })
  access_skynet(path_info, client_args)
end

Private Class Methods

access_skynet(path_info, args) click to toggle source
# File lib/skynet/accessor.rb, line 24
def access_skynet(path_info, args)
  method, path = Skynet::Splitter.clean(path_info)
  method, path, args = Skynet::Identifier.identify(method, path, args)

  @conn.send(method, *[path, args])
end
set_up_faraday() click to toggle source
# File lib/skynet/accessor.rb, line 16
def set_up_faraday
  Faraday.new(:url => "#{@client.skynet_url}/api") do |faraday|
    faraday.request  :url_encoded
    faraday.response :logger
    faraday.adapter  Faraday.default_adapter
  end
end