couchdb-ruby-query-server
couchdb-ruby-query-server copied to clipboard
map returns result of map function, not results of emit.
The test is only passed because emit is the last thing called in the test, and emit returns the result of all admits.
to verify, add "1" to the end of the emit-twice rspec function, in both javascript and ruby. passes in javascript, fails in ruby.
Anyway, patch attached.
diff --git a/lib/couch_db/view.rb b/lib/couch_db/view.rb
index 803cb07..0bf07ff 100644
--- a/lib/couch_db/view.rb
+++ b/lib/couch_db/view.rb
@@ -35,6 +35,15 @@ module CouchDB
def emit(key, value)
@results.push([key, value])
end
+
+ def run(*args)
+ begin
+ instance_exec *args, &@func
+ @results
+ rescue HaltedFunction => e
+ @error
+ end
+ end
end
def reduce(functions, vals)
thanks, I'll look at this this afternoon.