Class: SimplyCouch::Model::Views::ArrayPropertyViewSpec

Inherits:
SimplyCouch::Model::View::ModelViewSpec show all
Defined in:
lib/simply_couch/model/views/array_property_view_spec.rb

Constant Summary

Constants inherited from SimplyCouch::Model::View::ModelViewSpec

SimplyCouch::Model::View::ModelViewSpec::RUBY_CLASS_KEY

Constants inherited from SimplyCouch::Model::View::BaseViewSpec

SimplyCouch::Model::View::BaseViewSpec::DEFAULT_DIGEST_VIEW_NAMES, SimplyCouch::Model::View::BaseViewSpec::DEFAULT_LANGUAGE

Instance Attribute Summary

Attributes inherited from SimplyCouch::Model::View::BaseViewSpec

#design_document, #language, #lib, #list_function, #list_name, #reduce_function, #view_name, #view_parameters

Instance Method Summary collapse

Methods inherited from SimplyCouch::Model::View::ModelViewSpec

#process_results, #reduce_function, #view_parameters

Methods inherited from SimplyCouch::Model::View::BaseViewSpec

#initialize, #process_results

Constructor Details

This class inherits a constructor from SimplyCouch::Model::View::BaseViewSpec

Instance Method Details

#keyObject



19
20
21
# File 'lib/simply_couch/model/views/array_property_view_spec.rb', line 19

def key
  @options[:key]
end

#map_functionObject



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/simply_couch/model/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