Class: Actions::Middleware::RecurringLogic

Inherits:
Dynflow::Middleware
  • Object
show all
Defined in:
app/lib/actions/middleware/recurring_logic.rb

Instance Method Summary collapse

Instance Method Details

#delay(delay_options, *args) ⇒ Object

::Actions::Middleware::RecurringLogic

A middleware designed to make action repeatable. After an action is delayed, it checks whether the delay_options hash contains an id of a recurring logic. If so, it adds the task to the recurring logic’s task group, otherwise does nothing.

After the action’s plan phase the middleware checks if the task is associated with a task group of any recurring logic, in which case it triggers another repeat using the task group’s recurring logic, otherwise does nothing.



16
17
18
19
20
21
22
# File 'app/lib/actions/middleware/recurring_logic.rb', line 16

def delay(delay_options, *args)
  pass(delay_options, *args).tap do
    if delay_options[:recurring_logic_id]
      task.add_missing_task_groups(recurring_logic(delay_options).task_group)
    end
  end
end

#plan(*args) ⇒ Object



24
25
26
27
28
29
# File 'app/lib/actions/middleware/recurring_logic.rb', line 24

def plan(*args)
  pass(*args).tap do
    task_group = task.task_groups.find { |tg| tg.is_a? ::ForemanTasks::TaskGroups::RecurringLogicTaskGroup }
    task_group.recurring_logic.trigger_repeat(action.class, *args) if task_group
  end
end