# File lib/foreman_maintain/concerns/metadata.rb, line 84 def self.eval_dsl(metadata, &block) new(metadata).tap do |dsl| dsl.instance_eval(&block) end.data end
# File lib/foreman_maintain/concerns/metadata.rb, line 15 def initialize(data = {}) @data = data end
# File lib/foreman_maintain/concerns/metadata.rb, line 31 def confine(&block) @data[:confine_blocks] << block end
# File lib/foreman_maintain/concerns/metadata.rb, line 27 def description(description) @data[:description] = description end
Specify what feature the definition related to.
# File lib/foreman_maintain/concerns/metadata.rb, line 77 def for_feature(feature_label) @data[:for_feature] = feature_label confine do feature(feature_label) end end
# File lib/foreman_maintain/concerns/metadata.rb, line 19 def label(label) @data[:label] = label end
Mark the class as manual: this means the instance of class will not be initialized by detector to check the confine block to determine if it's valid on the system or not. The classes marked for manual detect need to be initialized in from other places (such as `additional_features` in Feature)
# File lib/foreman_maintain/concerns/metadata.rb, line 66 def manual_detection @data[:autodetect] = false end
Parametrize the definition.
+name+: Name (Symbol) of the attribute +description_or_options+: Description string or a Hash with options +options+: Hash with options (unless specified in +descriptions_or_options+) +&block+: block to be called when processing the data: can be used for validation and type-casing of the value: expected to return the value to be used
+:description+: String describing the parameter +:required+: true if required +:flag+: param is just a true/false value: not expecting other values
# File lib/foreman_maintain/concerns/metadata.rb, line 51 def param(name, descripiton_or_options = {}, options = {}, &block) case descripiton_or_options when String description = descripiton_or_options when Hash options = options.merge(descripiton_or_options) if descripiton_or_options.is_a?(Hash) end @data[:params][name] = Param.new(name, description, options, &block) end
in the block, define one or more preparation steps needed before executing this definition
# File lib/foreman_maintain/concerns/metadata.rb, line 72 def preparation_steps(&block) @data[:preparation_steps_blocks] << block end