Module: ForemanTasks::Concerns::ActionSubject
- Extended by:
 - ActiveSupport::Concern
 
- Included in:
 - HostActionSubject
 
- Defined in:
 - app/models/foreman_tasks/concerns/action_subject.rb
 
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
      6 7 8  | 
    
      # File 'app/models/foreman_tasks/concerns/action_subject.rb', line 6 def action_input_key self.class.name.demodulize.underscore end  | 
  
#all_related_resources ⇒ Object
Recursively searches for related resources of this one, avoiding cycles
      29 30 31 32 33 34 35 36 37  | 
    
      # File 'app/models/foreman_tasks/concerns/action_subject.rb', line 29 def mine = Set.new Array() = lambda do |resource| resource.is_a?(ActionSubject) ? resource. : [] end mine + mine.reduce(Set.new) { |s, resource| s + .call(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.
      24 25 26  | 
    
      # File 'app/models/foreman_tasks/concerns/action_subject.rb', line 24 def [] end  | 
  
#to_action_input ⇒ Object
      10 11 12 13 14 15 16  | 
    
      # File 'app/models/foreman_tasks/concerns/action_subject.rb', line 10 def to_action_input raise 'The resource needs to be saved first' if new_record? { id: id, name: name }.tap do |hash| hash.update(label: label) if respond_to? :label end end  |