class ForemanMaintain::Concerns::Metadata::DSL

Attributes

data[R]

Public Class Methods

eval_dsl(metadata, &block) click to toggle source
# 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
new(data = {}) click to toggle source
# File lib/foreman_maintain/concerns/metadata.rb, line 15
def initialize(data = {})
  @data = data
end

Public Instance Methods

confine(&block) click to toggle source
# File lib/foreman_maintain/concerns/metadata.rb, line 31
def confine(&block)
  @data[:confine_blocks] << block
end
description(description) click to toggle source
# File lib/foreman_maintain/concerns/metadata.rb, line 27
def description(description)
  @data[:description] = description
end
for_feature(feature_label) click to toggle source

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
label(label) click to toggle source
# File lib/foreman_maintain/concerns/metadata.rb, line 19
def label(label)
  @data[:label] = label
end
manual_detection() click to toggle source

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
param(name, descripiton_or_options = {}, options = {}, &block) click to toggle source

Parametrize the definition.

Arguments

+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

Options

+: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
preparation_steps(&block) click to toggle source

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
tags(*tags) click to toggle source
# File lib/foreman_maintain/concerns/metadata.rb, line 23
def tags(*tags)
  @data[:tags].concat(tags)
end