Class: CouchPotato::View::RawViewSpec

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

Overview

A view for custom map/reduce functions that returns the raw data fromcouchdb

example:

view :my_custom_view, :map => "function(doc) { emit(doc._id, null); }", :type => :raw, :reduce => nil

optionally you can pass in a results filter which you can use to process the raw couchdb results before returning them

example:

view :my_custom_view, :map => "function(doc) { emit(doc._id, null); }", :type => :raw, :results_filter => lambda{|results| results['rows].map{|row| row['value']}}

Instance Attribute Summary

Attributes inherited from BaseViewSpec

#design_document, #list_function, #list_name, #view_name, #view_parameters

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



12
13
14
# File 'lib/couch_potato/view/raw_view_spec.rb', line 12

def map_function
  options[:map]
end

#process_results(results) ⇒ Object



16
17
18
# File 'lib/couch_potato/view/raw_view_spec.rb', line 16

def process_results(results)
  options[:results_filter] ? options[:results_filter].call(results) : results
end

#reduce_functionObject



20
21
22
# File 'lib/couch_potato/view/raw_view_spec.rb', line 20

def reduce_function
  options[:reduce]
end