Method: Puppet::Pops::Types::TypeFactory.string

Defined in:
lib/puppet/pops/types/type_factory.rb

.string(size_type_or_value = nil, *deprecated_second_argument) ⇒ Object

Produces the String type based on nothing, a string value that becomes an exact match constraint, or a parameterized Integer type that constraints the size.



111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/puppet/pops/types/type_factory.rb', line 111

def self.string(size_type_or_value = nil, *deprecated_second_argument)
  if deprecated_second_argument.empty?
    size_type_or_value.nil? ? PStringType::DEFAULT : PStringType.new(size_type_or_value)
  else
    if Puppet[:strict] != :off
      #TRANSLATORS 'TypeFactory#string' is a class and method name and should not be translated
      message = _("Passing more than one argument to TypeFactory#string is deprecated")
      Puppet.warn_once('deprecations', "TypeFactory#string_multi_args", message)
    end
    deprecated_second_argument.size == 1 ? PStringType.new(deprecated_second_argument[0]) : PEnumType.new(*deprecated_second_argument)
  end
end