Sha256: 01ea1af679c152b43b6f36e11bbae7fc947976c4a0317dcb9d688c9161e66646

Contents?: true

Size: 746 Bytes

Versions: 13

Compression:

Stored size: 746 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'])
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 3 rubygems

Version Path
andrewtimberlake-couch_potato-0.2.8.1 lib/couch_potato/view/custom_view_spec.rb
andrewtimberlake-couch_potato-0.2.8.2 lib/couch_potato/view/custom_view_spec.rb
andrewtimberlake-couch_potato-0.2.8.3 lib/couch_potato/view/custom_view_spec.rb
andrewtimberlake-couch_potato-0.2.8.4 lib/couch_potato/view/custom_view_spec.rb
langalex-couch_potato-0.2.11 lib/couch_potato/view/custom_view_spec.rb
langalex-couch_potato-0.2.3 lib/couch_potato/view/custom_view_spec.rb
langalex-couch_potato-0.2.4 lib/couch_potato/view/custom_view_spec.rb
langalex-couch_potato-0.2.5 lib/couch_potato/view/custom_view_spec.rb
langalex-couch_potato-0.2.6 lib/couch_potato/view/custom_view_spec.rb
langalex-couch_potato-0.2.7 lib/couch_potato/view/custom_view_spec.rb
langalex-couch_potato-0.2.8 lib/couch_potato/view/custom_view_spec.rb
langalex-couch_potato-0.2.9 lib/couch_potato/view/custom_view_spec.rb
thefool808-couch_potato-0.2.7 lib/couch_potato/view/custom_view_spec.rb