Class: Couch::DocView
Constant Summary
Constants inherited from View
Constants included from Log
Instance Attribute Summary
Attributes inherited from Document
Class Method Summary collapse
Methods inherited from View
#all, find, #map, #map=, #reduce, #reduce=, #total_rows
Methods inherited from Document
async, #changed?, #database, database, #destroy, #dup, find, #id, #id=, #initialize, #inspect, instantiate, #new_record?, #reload, #rev, #save, #to_hash, #to_json, #type, #update
Methods included from DocExtensions
Constructor Details
This class inherits a constructor from Couch::Document
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Couch::Document
Class Method Details
.create(klass, name, opts = {}) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/couch/doc_view.rb', line 11 def self.create(klass, name, opts = {}) map = <<-JS function(doc) { if(doc.type == #{klass.name.to_json}) { emit(#{key_expression(opts[:keys])}, 1); } } JS reduce = "_sum" if opts[:mode] == :count super name, :map => map, :reduce => reduce end |