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



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

def abstract_class
  !(superclass < Metadata)
end

#advanced_run?Boolean

Returns:

  • (Boolean)


185
186
187
# File 'lib/foreman_maintain/concerns/metadata.rb', line 185

def advanced_run?
  [:advanced_run]
end

#afterObject



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

def after
  [:after] || []
end

#all_sub_classes(ignore_abstract_classes = true) ⇒ Object



136
137
138
139
140
141
142
143
# File 'lib/foreman_maintain/concerns/metadata.rb', line 136

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)


132
133
134
# File 'lib/foreman_maintain/concerns/metadata.rb', line 132

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

#beforeObject



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

def before
  [:before] || []
end

#descriptionObject



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

def description
  [:description] || to_s
end

#inherited(klass) ⇒ Object



117
118
119
# File 'lib/foreman_maintain/concerns/metadata.rb', line 117

def inherited(klass)
  sub_classes << klass
end

#initialize_metadataObject



189
190
191
192
193
194
195
196
197
198
199
200
201
# File 'lib/foreman_maintain/concerns/metadata.rb', line 189

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



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

def label
  [:label] || generate_label
end

#metadata(&block) ⇒ Object



145
146
147
148
149
150
151
# File 'lib/foreman_maintain/concerns/metadata.rb', line 145

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

#metadata_classObject



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

def 
  DSL
end

#paramsObject



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

def params
  [:params] || {}
end

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



207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
# File 'lib/foreman_maintain/concerns/metadata.rb', line 207

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)


203
204
205
# File 'lib/foreman_maintain/concerns/metadata.rb', line 203

def present?
  evaluate_confines
end

#run_once?Boolean

Returns:

  • (Boolean)


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

def run_once?
  [:run_once]
end

#sub_classesObject



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

def sub_classes
  @sub_classes ||= []
end

#tagsObject



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

def tags
  [:tags]
end