diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/extensions/couchrest.rb | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/extensions/couchrest.rb b/lib/extensions/couchrest.rb index df83c9f..290cd32 100644 --- a/lib/extensions/couchrest.rb +++ b/lib/extensions/couchrest.rb @@ -15,13 +15,19 @@ module CouchRest end class DesignMapper - def load_views(dir) + DEFAULT_REDUCE = <<-EOJS + function(key, values, rereduce) { + return sum(values); + } + EOJS + def load_views(dir, reduce=DEFAULT_REDUCE) Dir.glob("#{dir}/*.js") do |js| name = File.basename(js, '.js') file = File.open(js, 'r') + reduce = view name.to_sym, - :map => file.read, - :reduce => "function(key, values, rereduce) { return sum(values); }" + map: file.read, + reduce: reduce end end end |