class DRbQS::Task::TaskSet
DRbQS::Task::TaskSet
is a child class of DRbQS::Task
and consists of group of a number of tasks. Objects of the class are generated when we set the option :collect to {DRbQS::Task::Generator#set} and therefore we are unaware of the objects of DRbQS::TaskSet in many cases.
Attributes
original_note[R]
Public Class Methods
new(task_ary)
click to toggle source
Calls superclass method
DRbQS::Task::new
# File lib/drbqs/task/task.rb, line 154 def initialize(task_ary) @original_note = task_ary.map do |task| task.note end.compact! group_sym = get_group_sym(task_ary) if task_ary.all? { |task| !(Proc === task.hook) } container = DRbQS::Task::TaskSet::ContainerTask.new(task_ary) super(container, :exec, hook: :exec_all_hooks, note: note_string, group: group_sym) else container = DRbQS::Task::TaskSet::ContainerWithoutHook.new(task_ary) @original_task = task_ary super(container, :exec, note: note_string, group: group_sym) do |srv, result| result.each_with_index do |res, i| @original_task[i].exec_hook(srv, res) end end end end
Private Instance Methods
get_group_sym(task_ary)
click to toggle source
# File lib/drbqs/task/task.rb, line 173 def get_group_sym(task_ary) group_names = task_ary.map do |task| task.group end group_names.compact! group_names.uniq! raise ArgumentError, "Can not collect tasks with different groups." if group_names.size > 1 group_names[0] end
note_string()
click to toggle source
# File lib/drbqs/task/task.rb, line 184 def note_string str = "TaskSet" unless @original_note.empty? case @original_note.size when 1 str << ": " << @original_note[0] when 2 str << ": " << @original_note.join(", ") else str << ": " << @original_note[0] << ' - ' << @original_note[-1] end end str end