lib/evrythng/request.rb in evrythng-0.0.3 vs lib/evrythng/request.rb in evrythng-0.0.5
- old
+ new
@@ -1,40 +1,40 @@
module Evrythng
# Defines HTTP request methods
module Request
# Perform an HTTP GET request
- def get(path, options={}, raw=false)
- request(:get, path, options, raw)
+ def get(path, options={}, format=format)
+ request(:get, path, options, format)
end
# Perform an HTTP POST request
- def post(path, options={}, raw=false)
- request(:post, path, options, raw)
+ def post(path, options={}, format=format)
+ request(:post, path, options, format)
end
# Perform an HTTP PUT request
- def put(path, options={}, raw=false)
- request(:put, path, options, raw)
+ def put(path, options={}, format=format)
+ request(:put, path, options, format)
end
# Perform an HTTP DELETE request
- def delete(path, options={}, raw=false)
- request(:delete, path, options, raw)
+ def delete(path, options={}, format=format)
+ request(:delete, path, options, format)
end
private
# Perform an HTTP request
- def request(method, path, options, raw=false)
- response = connection(raw).send(method) do |request|
- case method
+ def request(method, path, options, format)
+ response = connection(format).send(method) do |request|
+ case method.to_sym
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
+ 'raw' == format.to_s.downcase ? response : response.body
end
end
end