norr-couchrest 0.30 → 0.30.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/couchrest/core/design.rb +4 -6
- data/lib/couchrest/mixins/design_doc.rb +3 -9
- metadata +1 -1
@@ -19,13 +19,11 @@ module CouchRest
|
|
19
19
|
key_emit = doc_keys.length == 1 ? "#{doc_keys.first}" : "[#{doc_keys.join(', ')}]"
|
20
20
|
guards = opts.delete(:guards) || []
|
21
21
|
guards.concat doc_keys
|
22
|
-
map_function = <<-
|
23
|
-
|
24
|
-
|
25
|
-
emit(#{key_emit}, null);
|
26
|
-
}
|
22
|
+
map_function = <<-RUBY
|
23
|
+
proc {|doc|
|
24
|
+
emit(#{key_emit}, nil) if (#{guards.join(' && ')})
|
27
25
|
}
|
28
|
-
|
26
|
+
RUBY
|
29
27
|
self['views'][method_name] = {
|
30
28
|
'map' => map_function
|
31
29
|
}
|
@@ -30,17 +30,11 @@ module CouchRest
|
|
30
30
|
|
31
31
|
def default_design_doc
|
32
32
|
{
|
33
|
-
"language" => "
|
33
|
+
"language" => "ruby",
|
34
34
|
"views" => {
|
35
35
|
'all' => {
|
36
|
-
'map' => "
|
37
|
-
|
38
|
-
emit(null,1);
|
39
|
-
}
|
40
|
-
}",
|
41
|
-
'reduce' => "function(keys, values) {
|
42
|
-
return sum(values);
|
43
|
-
}"
|
36
|
+
'map' => "proc {|doc|emit(nil,1) if doc['couchrest-type'].eql?('#{self.to_s}')}",
|
37
|
+
'reduce' => "proc{|ks,vs,rereduce|sum(vs)}"
|
44
38
|
}
|
45
39
|
}
|
46
40
|
}
|