fix for design doc url changes

This commit is contained in:
Chris Anderson 2009-03-09 13:12:28 -07:00
parent 2aeb90721e
commit 7b03c7ba25

View file

@ -61,12 +61,15 @@ module CouchRest
# paramaters as described in http://wiki.apache.org/couchdb/HttpViewApi # paramaters as described in http://wiki.apache.org/couchdb/HttpViewApi
def view(name, params = {}, &block) def view(name, params = {}, &block)
keys = params.delete(:keys) 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 if keys
CouchRest.post(url, {:keys => keys}) CouchRest.post(url, {:keys => keys})
else else
if block_given? if block_given?
@streamer.view(name, params, &block) @streamer.view("_design/#{dname}/_view/#{vname}", params, &block)
else else
CouchRest.get url CouchRest.get url
end end