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