Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

map returns result of map function, not results of emit. #1

Open
agrussellknives opened this issue Jun 30, 2010 · 1 comment
Open

Comments

@agrussellknives
Copy link

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)
@mattly
Copy link
Owner

mattly commented Jul 3, 2010

thanks, I'll look at this this afternoon.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant