Project

General

Profile

« Previous | Next » 

Revision 7619e2d8

Added by Marc Dequènes over 13 years ago

  • ID 7619e2d81f50a5cdb2ea921f811427322145aed6

[evol] Task-based client DSL §3 (pass errors and results to next step)

View differences:

lib/cyborghood/cyborg/dsl.rb
end
class Task < BaseDSL
attr_reader :bot
attr_reader :bot, :errors, :results
@@task_list = {}
def initialize(bot, name = nil, &block)
def initialize(bot, name = nil, previous_step_data = {}, &block)
@bot = bot
@name = name
@@task_list[@name] = self unless @name.nil?
@errors = (previous_step_data[:errors] || {}).freeze
@results = (previous_step_data[:results] || {}).freeze
@subtasks = []
@cancel_on_start_error = false
@cancel_run = false
......
def _check_finished
return unless _subtasks_finished?
error = false
next_step = {
next_step_data = {
:errors = {},
:results = {}
}
@subtasks.each do |subtask|
# z
next_step_data[:errors][subtask.name] = subtask.errors
next_step_data[:results].merge!(subtask.results)
end
cb = next_step_data[:errors].empty? ? @error_cb : @success_cb
self.class.new(name || @name, next_step_data, &cb) if cb
end
def _notification_criterias_match(msg, criterias)

Also available in: Unified diff