module Trailblazer::Activity::DSL::Linear::Helper::ClassMethods::Patch

Public Instance Methods

call(activity, path, customization) click to toggle source
# File lib/trailblazer/activity/dsl/linear/helper.rb, line 121
def call(activity, path, customization)
  task_id, *path = path

  patch =
    if task_id
      segment_activity = Introspect::Graph(activity).find(task_id).task
      patched_segment_activity = call(segment_activity, path, customization)

      # Replace the patched subprocess.
      -> { step Subprocess(patched_segment_activity), inherit: true, replace: task_id, id: task_id }
    else
      customization # apply the *actual* patch from the Subprocess() call.
    end

  patched_activity = Class.new(activity)
  patched_activity.class_exec(&patch)
  patched_activity
end
customize(activity, options:) click to toggle source
# File lib/trailblazer/activity/dsl/linear/helper.rb, line 109
def customize(activity, options:)
  options = options.is_a?(Proc) ?
    { [] => options } : # hash-wrapping with empty path, for patching given activity itself
    options

  options.each do |path, patch|
    activity = call(activity, path, patch) # TODO: test if multiple patches works!
  end

  activity
end