def matches(interests, msg)
action = msg['action']
interests.each do |interest|
satisfied = case interest
when :or_error
interests.clear if action == 'error_intercepted'
when :inactive
(FINAL_ACTIONS.include?(action) && @context.worker.inactive?)
when :empty
(action == 'terminated' && @context.storage.empty?('expressions'))
when Symbol
(action == 'dispatch' && msg['participant_name'] == interest.to_s)
when Fixnum
interests.delete(interest)
if (interest > 1)
interests << (interest - 1)
false
else
true
end
when Hash
interest.all? { |k, v|
k = 'tree.0' if k == 'exp_name'
Ruote.lookup(msg, k) == v
}
when /^[a-z_]+$/
(action == interest)
else
(FINAL_ACTIONS.include?(action) && msg['wfid'] == interest)
end
interests.delete(interest) if satisfied
end
if interests.include?(:or_error)
(interests.size < 2)
else
(interests.size < 1)
end
end