Method: Puppet::Pops::Types::PIterableType#instance?

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

#instance?(o, guard = nil) ⇒ 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:

  • (Boolean)


1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
# File 'lib/puppet/pops/types/types.rb', line 1414

def instance?(o, guard = nil)
  if @type.nil? || @type.assignable?(PAnyType::DEFAULT, guard)
    # Any element_type will do
    case o
    when Iterable, String, Hash, Array, Range, PEnumType
      true
    when Integer
      o >= 0
    when PIntegerType
      o.finite_range?
    when PTypeAliasType
      instance?(o.resolved_type, guard)
    else
      false
    end
  else
    assignable?(TypeCalculator.infer(o), guard)
  end
end