Module: ForemanTasks::Concerns::ActionSubject
- Extended by:
- ActiveSupport::Concern
- Included in:
- ArchitectureActionSubject, HostActionSubject
- Defined in:
- app/models/foreman_tasks/concerns/action_subject.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #action_input_key ⇒ Object
-
#all_related_resources ⇒ Object
Recursively searches for related resources of this one, avoiding cycles.
-
#related_resources ⇒ Object
objects, e.g.
- #to_action_input ⇒ Object
Instance Method Details
#action_input_key ⇒ Object
13 14 15 |
# File 'app/models/foreman_tasks/concerns/action_subject.rb', line 13 def action_input_key self.class.name.demodulize.underscore end |
#all_related_resources ⇒ Object
Recursively searches for related resources of this one, avoiding cycles
36 37 38 39 40 41 42 43 44 |
# File 'app/models/foreman_tasks/concerns/action_subject.rb', line 36 def mine = Set.new Array() = -> resource do resource.is_a?(ActionSubject) ? resource. : [] end mine + mine.reduce(Set.new) { |s, resource| s + .(resource) } end |
#related_resources ⇒ Object
objects, e.g. repository would return product it belongs to, product would return provider etc.
It’s used to link a task running on top of this resource to it’s related objects, so that is’t possible to see all the sync tasks for a product etc.
31 32 33 |
# File 'app/models/foreman_tasks/concerns/action_subject.rb', line 31 def [] end |
#to_action_input ⇒ Object
17 18 19 20 21 22 23 |
# File 'app/models/foreman_tasks/concerns/action_subject.rb', line 17 def to_action_input raise 'The resource needs to be saved first' if self.new_record? { id: id, name: name }.tap do |hash| hash.update(label: label) if self.respond_to? :label end end |