Method: Puppet::Parameter::ValueCollection#newvalue
- Defined in:
- lib/puppet/parameter/value_collection.rb
#newvalue(name, options = {}, &block) ⇒ 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.
TODO:
Option :event original comment says “event should be returned…”, is “returned” the correct word to use?
Defines a new valid value for a Puppet::Property. A valid value is specified as a literal (typically a Symbol), but can also be specified with a regexp.
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/puppet/parameter/value_collection.rb', line 133 def newvalue(name, = {}, &block) call_opt = [:call] unless call_opt.nil? devfail "Cannot use obsolete :call value '#{call_opt}' for property '#{self.class.name}'" unless call_opt == :none || call_opt == :instead # TRANSLATORS ':call' is a property and should not be translated = _("Property option :call is deprecated and no longer used.") += ' ' + _("Please remove it.") Puppet.deprecation_warning() = .reject { |k, _v| k == :call } end value = Puppet::Parameter::Value.new(name) @values[value.name] = value if value.regex? @regexes << value else @strings << value end .each { |opt, arg| value.send(opt.to_s + "=", arg) } if block_given? devfail "Cannot use :call value ':none' in combination with a block for property '#{self.class.name}'" if call_opt == :none value.block = block value.method ||= "set_#{value.name}" unless value.regex? elsif call_opt == :instead devfail "Cannot use :call value ':instead' without a block for property '#{self.class.name}'" end value end |