Sha256: ce421273422565c44440df060dc125cc8faf0c4c2f65e756952f470846e23fda
Contents?: true
Size: 978 Bytes
Versions: 5
Compression:
Stored size: 978 Bytes
Contents
module Cortex module Request def get(path, params = {}) response = connection.get do |r| r.url base_url + path r.params = params end parse_response(response) end def post(path, params = {}) response = connection.post do |r| r.url base_url + path r.body = params unless params.empty? end parse_response(response) end def put(path, params = {}) response = connection.put do |r| r.url base_url + path r.body = params unless params.empty? end parse_response(response) end def delete(path) response = connection.delete do |r| r.url base_url + path end parse_response(response) end def save(path, model) model[:id] ? put("#{path}/#{model[:id]}", model) : post(path, model) end def parse_response(response) Cortex::Result.new(response.body, response.headers, response.status) end end end
Version data entries
5 entries across 5 versions & 1 rubygems