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
1402 def self.register_ptype(loader, ir)
1403   create_ptype(loader, ir, 'AnyType',
1404     'type' => {
1405       KEY_TYPE => POptionalType.new(PTypeType::DEFAULT),
1406       KEY_VALUE => nil
1407     }
1408   )
1409 end

Public Instance Methods

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

Protected Instance Methods

_assignable?(o, guard) click to toggle source

@api private

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