Class: Puppet::Parameter::Value Private

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet/parameter/value.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Note:

this class should be used via the api methods in Puppet::Parameter and Puppet::Property

Describes an acceptable value for a parameter or property. An acceptable value is either specified as a literal value or a regular expression.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Value

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initializes the instance with a literal accepted value, or a regular expression. If anything else is passed, it is turned into a String, and then made into a Symbol.

Parameters:

  • name (Symbol, Regexp, Object)

    the value to accept, Symbol, a regular expression, or object to convert.



42
43
44
45
46
47
48
49
50
51
52
# File 'lib/puppet/parameter/value.rb', line 42

def initialize(name)
  if name.is_a?(Regexp)
    @name = name
  else
    # Convert to a string and then a symbol, so things like true/false
    # still show up as symbols.
    @name = convert(name)
  end

  @aliases = []
end

Instance Attribute Details

#blockObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



12
13
14
# File 'lib/puppet/parameter/value.rb', line 12

def block
  @block
end

#eventObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



11
12
13
# File 'lib/puppet/parameter/value.rb', line 11

def event
  @event
end

#invalidate_refreshesObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



12
13
14
# File 'lib/puppet/parameter/value.rb', line 12

def invalidate_refreshes
  @invalidate_refreshes
end

#methodObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



12
13
14
# File 'lib/puppet/parameter/value.rb', line 12

def method
  @method
end

#nameObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



11
12
13
# File 'lib/puppet/parameter/value.rb', line 11

def name
  @name
end

#optionsObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



11
12
13
# File 'lib/puppet/parameter/value.rb', line 11

def options
  @options
end

#required_featuresObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



12
13
14
# File 'lib/puppet/parameter/value.rb', line 12

def required_features
  @required_features
end

Instance Method Details

#alias(name) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Adds an alias for this value. Makes the given name be an alias for this acceptable value.

Parameters:

  • name (Symbol)

    the additional alias this value should be known as



19
20
21
# File 'lib/puppet/parameter/value.rb', line 19

def alias(name)
  @aliases << convert(name)
end

#aliasesArray<Symbol>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns all aliases (or an empty array).

Returns:

  • (Array<Symbol>)

    Returns all aliases (or an empty array).



26
27
28
# File 'lib/puppet/parameter/value.rb', line 26

def aliases
  @aliases.dup
end

#match?(value) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Checks if the given value matches the acceptance rules (literal value, regular expression, or one of the aliases.

Returns:



58
59
60
61
62
63
64
# File 'lib/puppet/parameter/value.rb', line 58

def match?(value)
  if regex?
    true if name =~ value.to_s
  else
    (name == convert(value) ? true : @aliases.include?(convert(value)))
  end
end

#regex?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns whether the accepted value is a regular expression or not.

Returns:

  • (Boolean)

    whether the accepted value is a regular expression or not.



69
70
71
# File 'lib/puppet/parameter/value.rb', line 69

def regex?
  @name.is_a?(Regexp)
end