Sha256: 18cf3730b56ed5d81b8d5ee6641433e7127877740aaa320cb088f20b4ebac40c
Contents?: true
Size: 1.24 KB
Versions: 1
Compression:
Stored size: 1.24 KB
Contents
module Sambatech # Defines HTTP request methods module Request # Perform an HTTP GET request def get(path, options={}, raw=false, unformatted=false) request(:get, path, options, raw, unformatted) end # Perform an HTTP POST request def post(path, options={}, raw=false, unformatted=false) request(:post, path, options, raw, unformatted) end # Perform an HTTP PUT request def put(path, options={}, raw=false, unformatted=false) request(:put, path, options, raw, unformatted) end # Perform an HTTP DELETE request def delete(path, options={}, raw=false, unformatted=false) request(:delete, path, options, raw, unformatted) end private # Perform an HTTP request def request(method, path, options, raw=false, unformatted=false) response = connection(raw).send(method) do |request| path = formatted_path(path) unless unformatted case method when :get, :delete request.url(path, options) when :post, :put request.path = path request.body = options unless options.empty? end end raw ? response : response.body end def formatted_path(path) [path].compact.join('.') end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sambatech-0.0.1 | lib/sambatech/request.rb |