Class: SimplyStored::Couch::Views::ArrayPropertyViewSpec

Inherits:
CouchPotato::View::ModelViewSpec
  • Object
show all
Defined in:
lib/simply_stored/couch/views/array_property_view_spec.rb

Instance Method Summary collapse

Instance Method Details

#map_functionObject



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/simply_stored/couch/views/array_property_view_spec.rb', line 5

def map_function
  "function(doc) {
     if(doc.ruby_class && doc.ruby_class == '#{@klass.name}') {
       if (#{formatted_key(key)}.constructor.toString().match(/function Array()/)) {
         for (var i in #{formatted_key(key)}) {
           emit(#{formatted_key(key)}[i], 1);
         }
       } else {
         emit(#{formatted_key(key)}, 1);
       }
     }
   }"
end