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 = " function(doc) { \n if(doc.type == \#{klass.name.to_json}) { emit(\#{key_expression(opts[:keys])}, 1); }\n }\n JS\n\n reduce = \"_sum\" if opts[:mode] == :count\n\n super name, :map => map, :reduce => reduce\nend\n" |
.find_or_create(klass, opts) ⇒ Object
2 3 4 5 6 7 8 9 |
# File 'lib/couch/doc_view.rb', line 2 def self.find_or_create(klass, opts) name = name_for(klass, opts) database.memoized_views[name] ||= begin Couch::DocView.find(name) || Couch::DocView.create(klass, name, opts) end end |