class ForemanTasks::ActionRule
Represents the cleanup mechanism for tasks
Attributes
after[R]
condition[R]
klass[R]
Public Class Methods
compose_include_rules(rules)
click to toggle source
# File lib/foreman_tasks/cleaner.rb, line 27 def self.compose_include_rules(rules) rules.group_by { |rule| [rule.after, rule.condition] } .map do |(after, condition), rules| ActionRule.new(rules.map(&:klass), after, condition) end end
new(klass, after, condition = nil)
click to toggle source
# File lib/foreman_tasks/cleaner.rb, line 7 def initialize(klass, after, condition = nil) @klass = klass @after = after @condition = condition end
Public Instance Methods
exclude_search()
click to toggle source
# File lib/foreman_tasks/cleaner.rb, line 13 def exclude_search "NOT (#{include_search})" end
include_search()
click to toggle source
# File lib/foreman_tasks/cleaner.rb, line 17 def include_search parts = if klass.is_a? Array ["label ^ (#{klass.join(', ')})"] else ["label = \"#{klass}\""] end parts << "(#{@condition})" if @condition '(' + parts.join(' AND ') + ')' end