lib/gems/request.rb in gems-0.0.3 vs lib/gems/request.rb in gems-0.0.4
- old
+ new
@@ -1,16 +1,25 @@
module Gems
module Request
- def get(path, options={}, format=:json)
+ def get(path, options={}, format=format)
request(:get, path, options, format)
end
private
def request(method, path, options, format)
response = connection(format).send(method) do |request|
- request.url(path, options)
+ request.url(formatted_path(path, format), options)
end
response.body
+ end
+
+ def formatted_path(path, format)
+ case format.to_sym
+ when :json, :xml
+ [path, format].compact.join('.')
+ when :marshal
+ path
+ end
end
end
end