lib/ruote/couch/storage.rb in ruote-couch-2.1.4 vs lib/ruote/couch/storage.rb in ruote-couch-2.1.5

- old
+ new

@@ -53,19 +53,19 @@ @dbs[type] = Database.new( @host, @port, type, "#{@prefix}ruote_#{type}") end - %w[ errors workitems ].each do |type| + @dbs['errors'] = WfidIndexedDatabase.new( + @host, @port, 'errors', "#{@prefix}ruote_errors") - @dbs[type] = WfidIndexedDatabase.new( - @host, @port, type, "#{@prefix}ruote_#{type}") - end - @dbs['expressions'] = WfidIndexedDatabase.new( @host, @port, 'expressions', "#{@prefix}ruote_expressions", false) + @dbs['workitems'] = WorkitemDatabase.new( + @host, @port, 'workitems', "#{@prefix}ruote_workitems") + put_configuration end def put (doc, opts={}) @@ -126,33 +126,36 @@ if db = @dbs[type] db.purge_docs! end end + # A provision made for workitems, allow to query them directly by + # participant name. + # + def by_participant (type, participant_name) + + raise NotImplementedError if type != 'workitems' + + @dbs['workitems'].by_participant(participant_name) + end + + def by_field (type, field, value=nil) + + raise NotImplementedError if type != 'workitems' + + @dbs['workitems'].by_field(field, value) + end + protected def put_configuration return if get('configurations', 'engine') conf = { '_id' => 'engine', 'type' => 'configurations' }.merge!(@options) put(conf) end - -# def put_design_document -# -# doc = Rufus::Jig::Json.decode( -# File.read(File.join(File.dirname(__FILE__), 'storage.json'))) -# -# current = @couch.get('_design/ruote') -# -# if current.nil? || doc['version'] >= (current['version'] || -1) -# -# @couch.delete(current) if current -# @couch.put(doc) -# end -# end end end end