Class: Ace::Task::Molecules::TaskReparenter

Inherits:
Object
  • Object
show all
Defined in:
lib/ace/task/molecules/task_reparenter.rb

Overview

Reparents tasks: promote subtask to standalone, convert to orchestrator, or demote standalone to subtask of another task.

Instance Method Summary collapse

Constructor Details

#initialize(root_dir:, config: {}) ⇒ TaskReparenter

Returns a new instance of TaskReparenter.

Parameters:

  • root_dir (String)

    Root directory for tasks

  • config (Hash) (defaults to: {})

    Configuration hash



16
17
18
19
# File 'lib/ace/task/molecules/task_reparenter.rb', line 16

def initialize(root_dir:, config: {})
  @root_dir = root_dir
  @config = config
end

Instance Method Details

#reparent(task, target:, resolve_ref:) ⇒ Models::Task

Reparent a task based on the target value.

Parameters:

  • task (Models::Task)

    The task to reparent

  • target (String)

    “none” (promote), “self” (orchestrator), or a parent ref

  • resolve_ref (Proc)

    Callable that resolves a ref to a Task (for “<ref>” case)

Returns:

  • (Models::Task)

    The reparented task at its new location



27
28
29
30
31
32
33
34
35
36
# File 'lib/ace/task/molecules/task_reparenter.rb', line 27

def reparent(task, target:, resolve_ref:)
  case target.downcase
  when "none"
    promote_to_standalone(task)
  when "self"
    convert_to_orchestrator(task)
  else
    demote_to_subtask(task, parent_ref: target, resolve_ref: resolve_ref)
  end
end