class Puppet::Pops::Types::PNotUndefType

Constants

DEFAULT

Public Class Methods

new(type = nil) click to toggle source
    # File lib/puppet/pops/types/types.rb
557 def initialize(type = nil)
558   super(type.class == PAnyType ? nil : type)
559 end
register_ptype(loader, ir) click to toggle source
    # File lib/puppet/pops/types/types.rb
548 def self.register_ptype(loader, ir)
549   create_ptype(loader, ir, 'AnyType',
550      'type' => {
551        KEY_TYPE => POptionalType.new(PTypeType::DEFAULT),
552        KEY_VALUE => nil
553      }
554   )
555 end

Public Instance Methods

instance?(o, guard = nil) click to toggle source
    # File lib/puppet/pops/types/types.rb
561 def instance?(o, guard = nil)
562   !(o.nil? || o == :undef) && (@type.nil? || @type.instance?(o, guard))
563 end
new_function() click to toggle source
    # File lib/puppet/pops/types/types.rb
582 def new_function
583   # If only NotUndef, then use Unit's null converter
584   if type.nil?
585     PUnitType.new_function(self)
586   else
587     type.new_function
588   end
589 end
normalize(guard = nil) click to toggle source
    # File lib/puppet/pops/types/types.rb
565 def normalize(guard = nil)
566   n = super
567   if n.type.nil?
568     n
569   else
570     if n.type.is_a?(POptionalType)
571       # No point in having an optional in a NotUndef
572       PNotUndefType.new(n.type.type).normalize
573     elsif !n.type.assignable?(PUndefType::DEFAULT)
574       # THe type is NotUndef anyway, so it can be stripped of
575       n.type
576     else
577       n
578     end
579   end
580 end

Protected Instance Methods

_assignable?(o, guard) click to toggle source

@api private

    # File lib/puppet/pops/types/types.rb
596 def _assignable?(o, guard)
597   o.is_a?(PAnyType) && !o.assignable?(PUndefType::DEFAULT, guard) && (@type.nil? || @type.assignable?(o, guard))
598 end