Sha256: 6bcccc08d15100ef8a7ca93659fd3cb38294de89cbdb8ebca9992aa4e7ed95b3

Contents?: true

Size: 841 Bytes

Versions: 5

Compression:

Stored size: 841 Bytes

Contents

module CouchPotato
  # 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']}}
  module View
    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

5 entries across 5 versions & 2 rubygems

Version Path
langalex-couch_potato-0.2.0 lib/couch_potato/view/raw_view_spec.rb
langalex-couch_potato-0.2.1 lib/couch_potato/view/raw_view_spec.rb
langalex-couch_potato-0.2.2 lib/couch_potato/view/raw_view_spec.rb
speedmax-couch_potato-0.2.0 lib/couch_potato/view/raw_view_spec.rb
speedmax-couch_potato-0.2.2 lib/couch_potato/view/raw_view_spec.rb