Class: CouchPotato::View::ModelViewSpec

Inherits:
BaseViewSpec show all
Defined in:
lib/couch_potato/view/model_view_spec.rb

Overview

a view to return model instances by searching its properties example: view :my_view, :key => :name

Direct Known Subclasses

PropertiesViewSpec

Instance Attribute Summary

Attributes inherited from BaseViewSpec

#design_document, #reduce_function, #view_name

Instance Method Summary collapse

Methods inherited from BaseViewSpec

#initialize

Constructor Details

This class inherits a constructor from CouchPotato::View::BaseViewSpec

Instance Method Details

#map_functionObject



11
12
13
14
15
# File 'lib/couch_potato/view/model_view_spec.rb', line 11

def map_function
  "function(doc) {
      emit(#{formatted_key(key)}, null);
   }"
end

#process_results(results) ⇒ Object



17
18
19
20
21
# File 'lib/couch_potato/view/model_view_spec.rb', line 17

def process_results(results)
  results['rows'].map do |row|
    klass.json_create row['doc']
  end
end

#view_parametersObject



7
8
9
# File 'lib/couch_potato/view/model_view_spec.rb', line 7

def view_parameters
  {:include_docs => true}.merge(super)
end