Module: ForemanMaintain::Concerns::Metadata::ClassMethods

Includes:
Finders
Defined in:
lib/foreman_maintain/concerns/metadata.rb

Instance Method Summary collapse

Methods included from Finders

#check, #detector, #feature, #find_all_scenarios, #find_checks, #find_procedures, #find_scenarios, #procedure

Instance Method Details

#abstract_classObject

Override if the class should be used as parent class only. By default, we assume the class that does’t inherit from class with Metadata is abstract = the base class of particular concept



120
121
122
# File 'lib/foreman_maintain/concerns/metadata.rb', line 120

def abstract_class
  !(superclass < Metadata)
end

#advanced_run?Boolean

Returns:

  • (Boolean)


181
182
183
# File 'lib/foreman_maintain/concerns/metadata.rb', line 181

def advanced_run?
  [:advanced_run]
end

#afterObject



173
174
175
# File 'lib/foreman_maintain/concerns/metadata.rb', line 173

def after
  [:after] || []
end

#all_sub_classes(ignore_abstract_classes = true) ⇒ Object



132
133
134
135
136
137
138
139
# File 'lib/foreman_maintain/concerns/metadata.rb', line 132

def all_sub_classes(ignore_abstract_classes = true)
  ret = []
  ret << self if !ignore_abstract_classes || !abstract_class
  sub_classes.each do |sub_class|
    ret.concat(sub_class.all_sub_classes(ignore_abstract_classes))
  end
  ret
end

#autodetect?Boolean

Returns:

  • (Boolean)


128
129
130
# File 'lib/foreman_maintain/concerns/metadata.rb', line 128

def autodetect?
  .fetch(:autodetect, true)
end

#beforeObject



169
170
171
# File 'lib/foreman_maintain/concerns/metadata.rb', line 169

def before
  [:before] || []
end

#descriptionObject



157
158
159
# File 'lib/foreman_maintain/concerns/metadata.rb', line 157

def description
  [:description] || to_s
end

#inherited(klass) ⇒ Object



113
114
115
# File 'lib/foreman_maintain/concerns/metadata.rb', line 113

def inherited(klass)
  sub_classes << klass
end

#initialize_metadataObject



185
186
187
188
189
190
191
192
193
194
195
196
197
# File 'lib/foreman_maintain/concerns/metadata.rb', line 185

def 
  { :tags => [],
    :confine_blocks => [],
    :params => {},
    :preparation_steps_blocks => [],
    :before => [],
    :after => [],
    :advanced_run => true }.tap do ||
    if superclass.respond_to?(:metadata)
      [:label] = superclass.[:label]
    end
  end
end

#labelObject



153
154
155
# File 'lib/foreman_maintain/concerns/metadata.rb', line 153

def label
  [:label] || generate_label
end

#metadata(&block) ⇒ Object



141
142
143
144
145
146
147
# File 'lib/foreman_maintain/concerns/metadata.rb', line 141

def (&block)
  @metadata ||= 
  if block
    .eval_dsl(@metadata, &block)
  end
  @metadata
end

#metadata_classObject



149
150
151
# File 'lib/foreman_maintain/concerns/metadata.rb', line 149

def 
  DSL
end

#paramsObject



165
166
167
# File 'lib/foreman_maintain/concerns/metadata.rb', line 165

def params
  [:params] || {}
end

#preparation_steps(recursion_depth = 0, trace = []) ⇒ Object



203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
# File 'lib/foreman_maintain/concerns/metadata.rb', line 203

def preparation_steps(recursion_depth = 0, trace = [])
  raise "Too many dependent steps #{trace}" if recursion_depth > MAX_PREPARATION_STEPS_DEPTH
  return @preparation_steps if defined?(@preparation_steps)
  preparation_steps = [:preparation_steps_blocks].map do |block|
    instance_exec(&block)
  end.flatten.compact
  preparation_steps.each { |step| raise ArgumentError unless step.is_a?(Executable) }
  all_preparation_steps = []
  preparation_steps.each do |step|
    all_preparation_steps.concat(
      step.preparation_steps(recursion_depth + 1, trace + [step])
    )
    all_preparation_steps << step
  end
  @preparation_steps = all_preparation_steps
end

#present?Boolean

Returns:

  • (Boolean)


199
200
201
# File 'lib/foreman_maintain/concerns/metadata.rb', line 199

def present?
  evaluate_confines
end

#run_once?Boolean

Returns:

  • (Boolean)


177
178
179
# File 'lib/foreman_maintain/concerns/metadata.rb', line 177

def run_once?
  [:run_once]
end

#sub_classesObject



124
125
126
# File 'lib/foreman_maintain/concerns/metadata.rb', line 124

def sub_classes
  @sub_classes ||= []
end

#tagsObject



161
162
163
# File 'lib/foreman_maintain/concerns/metadata.rb', line 161

def tags
  [:tags]
end