summaryrefslogtreecommitdiff
path: root/lib/extensions/couchrest.rb
diff options
context:
space:
mode:
authorazul <azul@leap.se>2014-07-14 07:52:12 +0200
committerazul <azul@leap.se>2014-07-14 07:52:12 +0200
commit07b141f3d677e993f02380b455738b20b9f0fe42 (patch)
tree553111ac07f6100738f29ddc7165fa800852f224 /lib/extensions/couchrest.rb
parent1c7308207a9ab46cfb60c72aceaee2b3c82281fe (diff)
parent3bbfdf29bbc40432c21e34fe84060cf9ae70273f (diff)
Merge pull request #175 from azul/feature/view-for-valid-certs
Feature/view for valid certs
Diffstat (limited to 'lib/extensions/couchrest.rb')
-rw-r--r--lib/extensions/couchrest.rb11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/extensions/couchrest.rb b/lib/extensions/couchrest.rb
index df83c9f..883073f 100644
--- a/lib/extensions/couchrest.rb
+++ b/lib/extensions/couchrest.rb
@@ -15,13 +15,18 @@ 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')
view name.to_sym,
- :map => file.read,
- :reduce => "function(key, values, rereduce) { return sum(values); }"
+ map: file.read,
+ reduce: reduce
end
end
end