module Connectify

Constants

VERSION

Public Class Methods

connection() click to toggle source
# File lib/connectify.rb, line 28
def self.connection
  @connection = Faraday.new(:url => @request_uri) do |faraday|
    faraday.request :url_encoded
    faraday.adapter Faraday.default_adapter
  end
end
path_for(uri, path, format) click to toggle source
# File lib/connectify.rb, line 24
def self.path_for uri, path, format
  @request_uri = uri + path + ".#{format}"
end
request(uri, path, format="json", type="GET", params={}) click to toggle source
# File lib/connectify.rb, line 5
def self.request uri, path, format="json", type="GET", params={}
  path_for uri, path, format
  resp = response type, params
  JSON.parse(resp)
end

Public Instance Methods

response(type, params) click to toggle source
# File lib/connectify.rb, line 11
def response type, params
  @response = case type
              when "POST"
                connection.post "", params
              when "PUT"
                connection.put "", params
              when "DELETE"
                connection.delete "", params
              else
                connection.get "", params
              end
end