adding ducktype support
This commit is contained in:
parent
adcaaaf59a
commit
d13159039a
2 changed files with 25 additions and 3 deletions
|
@ -273,7 +273,7 @@ module CouchRest
|
|||
|
||||
method_name = "by_#{keys.join('_and_')}"
|
||||
self.generated_design_doc ||= default_design_doc
|
||||
|
||||
ducktype = opts.delete(:ducktype)
|
||||
if opts[:map]
|
||||
view = {}
|
||||
view['map'] = opts.delete(:map)
|
||||
|
@ -288,7 +288,7 @@ module CouchRest
|
|||
key_emit = doc_keys.length == 1 ? "#{doc_keys.first}" : "[#{doc_keys.join(', ')}]"
|
||||
map_function = <<-JAVASCRIPT
|
||||
function(doc) {
|
||||
if (doc['couchrest-type'] == '#{type}' && #{key_protection}) {
|
||||
if (#{!ducktype ? "doc['couchrest-type'] == '#{type}' && " : ""}#{key_protection}) {
|
||||
emit(#{key_emit}, null);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue