From 5732c2fa48cf4af9af122ca5366f9ffffe5f22fb Mon Sep 17 00:00:00 2001
From: Azul <azul@leap.se>
Date: Thu, 3 Jan 2013 10:39:02 +0100
Subject: adding default reduce function to couch views read from files

---
 core/lib/extensions/couchrest.rb | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

(limited to 'core/lib/extensions')

diff --git a/core/lib/extensions/couchrest.rb b/core/lib/extensions/couchrest.rb
index 0dca632..5938df4 100644
--- a/core/lib/extensions/couchrest.rb
+++ b/core/lib/extensions/couchrest.rb
@@ -13,7 +13,9 @@ module CouchRest::Model::Designs
       Dir.glob("#{dir}/*.js") do |js|
         name = File.basename(js, '.js')
         file = File.open(js, 'r')
-        view name.to_sym, :map => file.read
+        view name.to_sym,
+          :map => file.read,
+          :reduce => "function(key, values, rereduce) { return sum(values); }"
       end
     end
   end
-- 
cgit v1.2.3