lib/open311/client/request.rb in open311-0.2.3 vs lib/open311/client/request.rb in open311-0.3.0

- old
+ new

@@ -1,36 +1,35 @@ module Open311 class Client module Request - def get(path, options={}, raw=false) - request(:get, path, options, raw) + def get(path, options = {}) + request(:get, path, options) end - def post(path, options={}, raw=false) - request(:post, path, options, raw) + def post(path, options = {}) + request(:post, path, options) end - def put(path, options={}, raw=false) - request(:put, path, options, raw) + def put(path, options = {}) + request(:put, path, options) end - def delete(path, options={}, raw=false) - request(:delete, path, options, raw) + def delete(path, options = {}) + request(:delete, path, options) end - private + private - def request(method, path, options, raw) - response = connection(raw).send(method) do |request| + def request(method, path, options) + connection.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.body end def formatted_path(path) [path, format].compact.join('.') end