Class: CouchPotato::View::CustomViewSpec

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

Overview

a view for custom map/reduce functions that still returns model instances example: view :my_custom_view, :map => “function(doc) { emit(doc._id, null); }”, :include_docs => true, :type => :custom, :reduce => nil

Instance Attribute Summary

Attributes inherited from BaseViewSpec

#design_document, #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



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

def map_function
  options[:map]
end

#process_results(results) ⇒ Object



19
20
21
22
23
# File 'lib/couch_potato/view/custom_view_spec.rb', line 19

def process_results(results)
  results['rows'].map do |row|
    klass.json_create row['doc'] || row['value'].merge(:_id => row['id'])
  end
end

#reduce_functionObject



11
12
13
# File 'lib/couch_potato/view/custom_view_spec.rb', line 11

def reduce_function
  options[:reduce]
end

#view_parametersObject



15
16
17
# File 'lib/couch_potato/view/custom_view_spec.rb', line 15

def view_parameters
  {:include_docs => options[:include_docs] || false}.merge(super)
end