Class: Puppet::Pops::Types::PNotUndefType Private

Inherits:
PTypeWithContainedType show all
Defined in:
lib/puppet/pops/types/types.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

API:

  • private

Constant Summary collapse

DEFAULT =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

API:

  • private

PNotUndefType.new

Instance Attribute Summary

Attributes inherited from PTypeWithContainedType

#type

Instance Method Summary collapse

Methods inherited from PTypeWithContainedType

#accept, #eql?, #generalize, #hash

Methods inherited from PAnyType

#==, #accept, #assignable?, #callable?, #callable_args?, #eql?, #generalize, #hash, #iterable?, #iterable_type, #kind_of_callable?, #simple_name, #to_alias_expanded_s, #to_s

Methods included from Visitable

#accept

Constructor Details

#initialize(type = nil) ⇒ PNotUndefType

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 a new instance of PNotUndefType.

API:

  • private



397
398
399
# File 'lib/puppet/pops/types/types.rb', line 397

def initialize(type = nil)
  super(type.class == PAnyType ? nil : type)
end

Instance Method Details

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

API:

  • private



401
402
403
# File 'lib/puppet/pops/types/types.rb', line 401

def instance?(o)
  !(o.nil? || o == :undef) && (@type.nil? || @type.instance?(o))
end

#normalize(guard = nil) ⇒ Object

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.

API:

  • private



405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
# File 'lib/puppet/pops/types/types.rb', line 405

def normalize(guard = nil)
  n = super
  if n.type.nil?
    n
  else
    if n.type.is_a?(POptionalType)
      # No point in having an optional in a NotUndef
      PNotUndef.new(n.type.type).normalize
    elsif !n.type.assignable?(PUndefType::DEFAULT)
      # THe type is NotUndef anyway, so it can be stripped of
      n.type
    else
      n
     end
  end
end