Sha256: 9127aa894a68e4927c37facb9ed6193b5a6f4133daac06778f6a89aa3ca08680

Contents?: true

Size: 877 Bytes

Versions: 58

Compression:

Stored size: 877 Bytes

Contents

module CouchPotato
  module View
    # 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']}}
    class RawViewSpec < BaseViewSpec
      def map_function
        options[:map]
      end
      
      def process_results(results)
        options[:results_filter] ? options[:results_filter].call(results) : results
      end
      
      def reduce_function
        options[:reduce]
      end
    end
  end
end

Version data entries

58 entries across 58 versions & 6 rubygems

Version Path
andrewtimberlake-couch_potato-0.2.8.1 lib/couch_potato/view/raw_view_spec.rb
andrewtimberlake-couch_potato-0.2.8.2 lib/couch_potato/view/raw_view_spec.rb
andrewtimberlake-couch_potato-0.2.8.3 lib/couch_potato/view/raw_view_spec.rb
andrewtimberlake-couch_potato-0.2.8.4 lib/couch_potato/view/raw_view_spec.rb
langalex-couch_potato-0.2.11 lib/couch_potato/view/raw_view_spec.rb
langalex-couch_potato-0.2.12 lib/couch_potato/view/raw_view_spec.rb
langalex-couch_potato-0.2.3 lib/couch_potato/view/raw_view_spec.rb
langalex-couch_potato-0.2.4 lib/couch_potato/view/raw_view_spec.rb
langalex-couch_potato-0.2.5 lib/couch_potato/view/raw_view_spec.rb
langalex-couch_potato-0.2.6 lib/couch_potato/view/raw_view_spec.rb
langalex-couch_potato-0.2.7 lib/couch_potato/view/raw_view_spec.rb
langalex-couch_potato-0.2.8 lib/couch_potato/view/raw_view_spec.rb
langalex-couch_potato-0.2.9 lib/couch_potato/view/raw_view_spec.rb
thefool808-couch_potato-0.2.7 lib/couch_potato/view/raw_view_spec.rb
couch_potato-0.7.1 lib/couch_potato/view/raw_view_spec.rb
couch_potato-0.7.0 lib/couch_potato/view/raw_view_spec.rb
couch_potato-0.7.0.pre.1 lib/couch_potato/view/raw_view_spec.rb
couch_potato-0.6.0 lib/couch_potato/view/raw_view_spec.rb
couch_potato-0.5.7 lib/couch_potato/view/raw_view_spec.rb
couch_potato-rails2-0.5.10 lib/couch_potato/view/raw_view_spec.rb