class Puppet::Pops::Types::PIterableType

Constants

DEFAULT

Public Class Methods

register_ptype(loader, ir) click to toggle source
     # File lib/puppet/pops/types/types.rb
1401 def self.register_ptype(loader, ir)
1402   create_ptype(loader, ir, 'AnyType',
1403     'type' => {
1404       KEY_TYPE => POptionalType.new(PTypeType::DEFAULT),
1405       KEY_VALUE => nil
1406     }
1407   )
1408 end

Public Instance Methods

element_type() click to toggle source
     # File lib/puppet/pops/types/types.rb
1410 def element_type
1411   @type
1412 end
instance?(o, guard = nil) click to toggle source
     # File lib/puppet/pops/types/types.rb
1414 def instance?(o, guard = nil)
1415   if @type.nil? || @type.assignable?(PAnyType::DEFAULT, guard)
1416     # Any element_type will do
1417     case o
1418     when Iterable, String, Hash, Array, Range, PEnumType
1419       true
1420     when Integer
1421       o >= 0
1422     when PIntegerType
1423       o.finite_range?
1424     when PTypeAliasType
1425       instance?(o.resolved_type, guard)
1426     else
1427       false
1428     end
1429   else
1430     assignable?(TypeCalculator.infer(o), guard)
1431   end
1432 end
iterable?(guard = nil) click to toggle source
     # File lib/puppet/pops/types/types.rb
1434 def iterable?(guard = nil)
1435   true
1436 end
iterable_type(guard = nil) click to toggle source
     # File lib/puppet/pops/types/types.rb
1438 def iterable_type(guard = nil)
1439   self
1440 end

Protected Instance Methods

_assignable?(o, guard) click to toggle source

@api private

     # File lib/puppet/pops/types/types.rb
1447 def _assignable?(o, guard)
1448   if @type.nil? || @type.assignable?(PAnyType::DEFAULT, guard)
1449     # Don't request the iterable_type. Since this Iterable accepts Any element, it is enough that o is iterable.
1450     o.iterable?
1451   else
1452     o = o.iterable_type
1453     o.nil? || o.element_type.nil? ? false : @type.assignable?(o.element_type, guard)
1454   end
1455 end