Ruote::Couch::WfidIndexedDatabase

A Couch database with a by_wfid view.

Public Class Methods

design_doc() click to toggle source

Returns the design document that goes with this class of database

     # File lib/ruote/couch/database.rb, line 235
235:     def self.design_doc
236: 
237:       self.allocate.send(:design_doc)
238:     end

Public Instance Methods

by_wfid(wfid) click to toggle source

Used by WorkitemDatabase#query

     # File lib/ruote/couch/database.rb, line 227
227:     def by_wfid (wfid)
228: 
229:       #get_many(/!#{wfid}$/, {})
230:       get_many(wfid, {})
231:     end
get_many(key, opts) click to toggle source

The get_many used by errors, expressions and schedules.

     # File lib/ruote/couch/database.rb, line 216
216:     def get_many (key, opts)
217: 
218:       return super(key, opts) unless key.is_a?(String)
219: 
220:       # key is a wfid
221: 
222:       query("_design/ruote/_view/by_wfid?key=%22#{key}%22&include_docs=true")
223:     end

Protected Instance Methods

design_doc() click to toggle source
     # File lib/ruote/couch/database.rb, line 242
242:     def design_doc
243: 
244:       {
245:         '_id' => '_design/ruote',
246:         'views' => {
247:           'by_wfid' => {
248:             'map' => %{
249:               function (doc) {
250:                 if (doc.wfid) emit(doc.wfid, null);
251:                 else if (doc.fei) emit(doc.fei.wfid, null);
252:               }
253:             }
254:           }
255:         }
256:       }
257:     end
prepare() click to toggle source
     # File lib/ruote/couch/database.rb, line 259
259:     def prepare
260: 
261:       d = @couch.get('_design/ruote')
262: 
263:       return if d && d['views'] == design_doc['views']
264: 
265:       d ||= design_doc
266:       d['views'] = design_doc['views']
267: 
268:       @couch.put(design_doc)
269:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.