lib/ruote/engine.rb in ruote-2.1.8 vs lib/ruote/engine.rb in ruote-2.1.9
- old
+ new
@@ -147,11 +147,11 @@
# a process instance.
#
def process (wfid)
exps = @storage.get_many('expressions', /!#{wfid}$/)
- errs = @storage.get_many('errors', /!#{wfid}$/)
+ errs = self.errors( wfid )
return nil if exps.empty? && errs.empty?
ProcessStatus.new(@context, exps, errs)
end
@@ -161,11 +161,11 @@
# WARNING : this is an expensive operation.
#
def processes
exps = @storage.get_many('expressions')
- errs = @storage.get_many('errors')
+ errs = self.errors
by_wfid = {}
exps.each do |exp|
(by_wfid[exp['fei']['wfid']] ||= [ [], [] ]).first << exp
@@ -173,9 +173,17 @@
errs.each do |err|
(by_wfid[err['msg']['fei']['wfid']] ||= [ [], [] ]).last << err
end
by_wfid.values.collect { |xs, rs| ProcessStatus.new(@context, xs, rs) }
+ end
+
+ # Returns an array of current errors (hashes)
+ #
+ def errors( wfid = nil )
+ wfid.nil? ?
+ @storage.get_many('errors') :
+ @storage.get_many('errors', /!#{wfid}$/)
end
def shutdown
@context.shutdown