Module: Trailblazer::Activity::Adds::FriendlyInterface

Defined in:
lib/trailblazer/activity/adds.rb

Overview

Adds.apply_adds(pipeline, adds) end

Class Method Summary collapse

Class Method Details

.adds_for(inserts) ⇒ Object

Translate a collection of friendly interface to ADDS. This is a mini-DSL, if you want.

Returns:

  • Array of ADDS



43
44
45
46
47
# File 'lib/trailblazer/activity/adds.rb', line 43

def self.adds_for(inserts)
  inserts.collect do |task, options|
    build_adds(task, **options)
  end
end

.build_adds(task, id:, prepend: "task_wrap.call_task", append: false) ⇒ Object



50
51
52
53
54
55
56
57
58
# File 'lib/trailblazer/activity/adds.rb', line 50

def self.build_adds(task, id:, prepend: "task_wrap.call_task", append: false)
  insert, insert_id =
    (append === false) ? [:Prepend, prepend] : [:Append, append]

  {
    insert: [Activity::Adds::Insert.method(insert), insert_id],
    row:    TaskWrap::Pipeline::Row(id, task)
  }
end