Module: ForemanTasks::Concerns::ActionTriggering
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/models/foreman_tasks/concerns/action_triggering.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#create_action ⇒ Object
These three *_action methods are called before the save/destroy actually occurs.
- #destroy ⇒ Object
- #destroy_action ⇒ Object
-
#disable_dynflow_hooks ⇒ Object
this can be used when HostActionSubject is used for orchestration but you want to avoid triggering more tasks by ActiveRecord callbacks within run/finalize phase of your task e.g.
- #enable_dynflow_hooks ⇒ Object
- #save ⇒ Object
- #save! ⇒ Object
-
#update ⇒ Object
(also: #update_attributes)
In order to use host.<attribute>_changed?, we must assign_attributes to the host record for these update and update! methods.
- #update! ⇒ Object (also: #update_attributes!)
- #update_action ⇒ Object
Class Method Details
.prepended(base) ⇒ Object
10 11 12 13 14 |
# File 'app/models/foreman_tasks/concerns/action_triggering.rb', line 10 def self.prepended(base) base.after_create :plan_hook_action base.after_update :plan_hook_action base.after_destroy :plan_hook_action end |
Instance Method Details
#create_action ⇒ Object
These three *_action methods are called before the save/destroy actually occurs
18 |
# File 'app/models/foreman_tasks/concerns/action_triggering.rb', line 18 def create_action; end |
#destroy ⇒ Object
34 35 36 |
# File 'app/models/foreman_tasks/concerns/action_triggering.rb', line 34 def destroy dynflow_task_wrap(:destroy) { super } end |
#destroy_action ⇒ Object
24 |
# File 'app/models/foreman_tasks/concerns/action_triggering.rb', line 24 def destroy_action; end |
#disable_dynflow_hooks ⇒ Object
this can be used when HostActionSubject is used for orchestration but you want to avoid triggering more tasks by ActiveRecord callbacks within run/finalize phase of your task e.g. host.disable_dynflow_hooks { |h| h.save }
55 56 57 58 59 60 61 62 63 64 65 |
# File 'app/models/foreman_tasks/concerns/action_triggering.rb', line 55 def disable_dynflow_hooks @_disable_dynflow_hooks = true if block_given? begin yield(self) ensure @_disable_dynflow_hooks = false end end end |
#enable_dynflow_hooks ⇒ Object
67 68 69 |
# File 'app/models/foreman_tasks/concerns/action_triggering.rb', line 67 def enable_dynflow_hooks @_disable_dynflow_hooks = false end |
#save ⇒ Object
26 27 28 |
# File 'app/models/foreman_tasks/concerns/action_triggering.rb', line 26 def save(...) dynflow_task_wrap(:save) { super(...) } end |
#save! ⇒ Object
30 31 32 |
# File 'app/models/foreman_tasks/concerns/action_triggering.rb', line 30 def save!(...) dynflow_task_wrap(:save) { super(...) } end |
#update ⇒ Object Also known as: update_attributes
In order to use host.<attribute>_changed?, we must assign_attributes to the host record for these update and update! methods.
40 41 42 43 |
# File 'app/models/foreman_tasks/concerns/action_triggering.rb', line 40 def update(...) assign_attributes(...) dynflow_task_wrap(:save) { save } end |
#update! ⇒ Object Also known as: update_attributes!
46 47 48 49 |
# File 'app/models/foreman_tasks/concerns/action_triggering.rb', line 46 def update!(...) assign_attributes(...) dynflow_task_wrap(:save) { save! } end |
#update_action ⇒ Object
21 |
# File 'app/models/foreman_tasks/concerns/action_triggering.rb', line 21 def update_action; end |