Class: ForemanTasks::Link
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- ForemanTasks::Link
- Defined in:
- app/models/foreman_tasks/link.rb
Class Method Summary collapse
- .build_related_links(resource, task) ⇒ Object
-
.link!(resource, task) ⇒ Object
Assigns the resource to the task to easily track the task in context of the resource.
- .link_resource_and_related!(resource, task) ⇒ Object
-
.owner!(user, task) ⇒ Object
Records the information about the user that triggered the task.
Class Method Details
.build_related_links(resource, task) ⇒ Object
35 36 37 38 39 |
# File 'app/models/foreman_tasks/link.rb', line 35 def (resource, task) (resource).map do || build(, task) end end |
.link!(resource, task) ⇒ Object
Assigns the resource to the task to easily track the task in context of the resource. This doesn’t prevent other actions to lock the resource and should be used only for actions that tolerate other actions to be performed on the resource. Usually, this shouldn’t needed to be done through the action directly, because the lock should assign it’s parent objects to the action recursively (using related_resources
method in model objects)
19 20 21 22 23 |
# File 'app/models/foreman_tasks/link.rb', line 19 def link!(resource, task) link = build(resource, task) link.save! link end |
.link_resource_and_related!(resource, task) ⇒ Object
30 31 32 33 |
# File 'app/models/foreman_tasks/link.rb', line 30 def (resource, task) link!(resource, task) (resource, task).each(&:save!) end |
.owner!(user, task) ⇒ Object
Records the information about the user that triggered the task
26 27 28 |
# File 'app/models/foreman_tasks/link.rb', line 26 def owner!(user, task) link!(user, task) end |