lib/evrythng/request.rb in evrythng-0.0.5 vs lib/evrythng/request.rb in evrythng-0.1.0

- old
+ new

@@ -1,40 +1,40 @@ module Evrythng # Defines HTTP request methods module Request + # Perform an HTTP DELETE request + def delete(path, params={}, options={}) + request(:delete, path, params, options) + end + # Perform an HTTP GET request - def get(path, options={}, format=format) - request(:get, path, options, format) + def get(path, params={}, options={}) + request(:get, path, params, options) end # Perform an HTTP POST request - def post(path, options={}, format=format) - request(:post, path, options, format) + def post(path, params={}, options={}) + request(:post, path, params, options) end # Perform an HTTP PUT request - def put(path, options={}, format=format) - request(:put, path, options, format) + def put(path, params={}, options={}) + request(:put, path, params, options) end - # Perform an HTTP DELETE request - def delete(path, options={}, format=format) - request(:delete, path, options, format) - end - private # Perform an HTTP request - def request(method, path, options, format) - response = connection(format).send(method) do |request| + def request(method, path, params, options) + response = connection(options).send(method) do |request| case method.to_sym - when :get, :delete - request.url(path, options) + when :delete, :get + request.url(path, params) when :post, :put request.path = path - request.body = options unless options.empty? + request.body = params unless params.empty? end end - 'raw' == format.to_s.downcase ? response : response.body + options[:raw] ? response : response.body end end end