fix for design doc url changes

This commit is contained in:
Chris Anderson 2009-03-09 13:12:28 -07:00 committed by Matt Aimonetti
parent bfff491202
commit b3a6a081fd

View file

@ -61,12 +61,15 @@ module CouchRest
# paramaters as described in http://wiki.apache.org/couchdb/HttpViewApi
def view(name, params = {}, &block)
keys = params.delete(:keys)
url = CouchRest.paramify_url "#{@uri}/_view/#{name}", params
name = name.split('/') # I think this will always be length == 2, but maybe not...
dname = name.shift
vname = name.join('/')
url = CouchRest.paramify_url "#{@uri}/_design/#{dname}/_view/#{vname}", params
if keys
CouchRest.post(url, {:keys => keys})
else
if block_given?
@streamer.view(name, params, &block)
@streamer.view("_design/#{dname}/_view/#{vname}", params, &block)
else
CouchRest.get url
end