Sha256: 9181919dafd783d91f044d7c5e83c1d1b0b29a4a54a8eb6021d856e9befcaa91

Contents?: true

Size: 760 Bytes

Versions: 2

Compression:

Stored size: 760 Bytes

Contents

module CouchPotato
  module View
    # 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
    class CustomViewSpec < BaseViewSpec
      def map_function
        options[:map]
      end
      
      def reduce_function
        options[:reduce]
      end
      
      def view_parameters
        {:include_docs => options[:include_docs] || false}.merge(super)
      end
      
      def process_results(results)
        results['rows'].map do |row|
          klass.json_create row['doc'] || row['value'].merge(:_id => row['id'] || row['key'])
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
langalex-couch_potato-0.2.12 lib/couch_potato/view/custom_view_spec.rb
couch_potato-0.2.12 lib/couch_potato/view/custom_view_spec.rb