Class: Actions::Base
- Inherits:
-
Dynflow::Action
- Object
- Dynflow::Action
- Actions::Base
- Includes:
- Helpers::LifecycleLogging, TaskSynchronization
- Defined in:
- app/lib/actions/base.rb
Direct Known Subclasses
Instance Method Summary collapse
- #already_running? ⇒ Boolean
-
#humanized_errors ⇒ Object
This method should return String or Array<String> describing the errors during the action.
-
#humanized_input ⇒ Object
This method should return String or Array<String> describing input for the task.
-
#humanized_name ⇒ Object
This method should return humanized description of the action, e.g.
-
#humanized_output ⇒ Object
This method should return String describing output for the task.
- #notify_paused(*_args) ⇒ Object
- #serializer_class ⇒ Object
- #task ⇒ Object
-
#task_input ⇒ Object
This method says what data form input gets into the task details in Rest API By default, it sends the whole input there.
-
#task_output ⇒ Object
This method says what data form output gets into the task details in Rest API It should aggregate the important data that are worth to propagate to Rest API, perhaps also aggraget data from subactions if needed (using
all_actions
) method of Dynflow::Action::Presenter.
Methods included from TaskSynchronization
included, #sync_execution_plan_to_task
Methods included from Helpers::LifecycleLogging
included, #log_task_state_change
Instance Method Details
#already_running? ⇒ Boolean
51 52 53 54 |
# File 'app/lib/actions/base.rb', line 51 def already_running? ForemanTasks::Task::DynflowTask.for_action(self.class) .running.where('external_id != ?', execution_plan_id).any? end |
#humanized_errors ⇒ Object
This method should return String or Array<String> describing the errors during the action
45 46 47 48 49 |
# File 'app/lib/actions/base.rb', line 45 def humanized_errors execution_plan.steps_in_state(:skipped, :skipping, :error).map do |step| step.error. if step.error end.compact end |
#humanized_input ⇒ Object
This method should return String or Array<String> describing input for the task
33 34 35 |
# File 'app/lib/actions/base.rb', line 33 def humanized_input '' end |
#humanized_name ⇒ Object
This method should return humanized description of the action, e.g. “Install package”
28 29 30 |
# File 'app/lib/actions/base.rb', line 28 def humanized_name self.class.name.demodulize.underscore.humanize end |
#humanized_output ⇒ Object
This method should return String describing output for the task. It should aggregate the data from subactions as well and it’s used for humanized description of restuls of the action
40 41 42 |
# File 'app/lib/actions/base.rb', line 40 def humanized_output '' end |
#notify_paused(*_args) ⇒ Object
60 61 62 |
# File 'app/lib/actions/base.rb', line 60 def notify_paused(*_args) task.build_notifications.each(&:deliver!) if root_action? end |
#serializer_class ⇒ Object
56 57 58 |
# File 'app/lib/actions/base.rb', line 56 def serializer_class ::Actions::Serializers::ActiveRecordSerializer end |
#task ⇒ Object
9 10 11 |
# File 'app/lib/actions/base.rb', line 9 def task @task ||= ::ForemanTasks::Task::DynflowTask.where(:external_id => execution_plan_id).first! end |
#task_input ⇒ Object
This method says what data form input gets into the task details in Rest API By default, it sends the whole input there.
15 16 17 |
# File 'app/lib/actions/base.rb', line 15 def task_input input end |
#task_output ⇒ Object
This method says what data form output gets into the task details in Rest API It should aggregate the important data that are worth to propagate to Rest API, perhaps also aggraget data from subactions if needed (using all_actions
) method of Dynflow::Action::Presenter
23 24 25 |
# File 'app/lib/actions/base.rb', line 23 def task_output output end |