Method: Puppet::Pops::Types::TypeCalculator#type
- Defined in:
- lib/puppet/pops/types/type_calculator.rb
#type(c) ⇒ Object
Answers ‘what is the Puppet Type corresponding to the given Ruby class’
213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 |
# File 'lib/puppet/pops/types/type_calculator.rb', line 213 def type(c) raise ArgumentError, 'Argument must be a Module' unless c.is_a? Module # Can't use a visitor here since we don't have an instance of the class if c <= Integer type = PIntegerType::DEFAULT elsif c == Float type = PFloatType::DEFAULT elsif c == Numeric type = PNumericType::DEFAULT elsif c == String type = PStringType::DEFAULT elsif c == Regexp type = PRegexpType::DEFAULT elsif c == NilClass type = PUndefType::DEFAULT elsif c == FalseClass || c == TrueClass type = PBooleanType::DEFAULT elsif c == Class type = PTypeType::DEFAULT elsif c == Array # Assume array of any type = PArrayType::DEFAULT elsif c == Hash # Assume hash of any type = PHashType::DEFAULT else type = PRuntimeType.new(:ruby, c.name) end type end |