Sha256: 22010008c882367557ca3839a4f008ead8b536c9ce4683d6b4c6e4d1901ba4e9
Contents?: true
Size: 850 Bytes
Versions: 2
Compression:
Stored size: 850 Bytes
Contents
module CouchPotato module View # A view to return model instances by searching its properties # # example: # view :my_view, :key => :name class ModelViewSpec < BaseViewSpec def view_parameters {:include_docs => true}.merge(super) end def map_function "function(doc) { emit(#{formatted_key(key)}, null); }" end def process_results(results) results['rows'].map do |row| klass.json_create row['doc'] end end private def key options[:key] end def formatted_key(key) if key.is_a? Array '[' + key.map{|attribute| formatted_key(attribute)}.join(', ') + ']' else "doc['#{key}']" end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
langalex-couch_potato-0.2.3 | lib/couch_potato/view/model_view_spec.rb |
langalex-couch_potato-0.2.4 | lib/couch_potato/view/model_view_spec.rb |