Class: Puppet::Pops::Types::PTypeWithContainedType Abstract

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

Overview

This class is abstract.

Encapsulates common behavior for a type that contains one type

Constant Summary

Constants inherited from PAnyType

Puppet::Pops::Types::PAnyType::DEFAULT

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from PAnyType

#==, #assignable?, #callable?, #callable_args?, #callable_with?, #check_self_recursion, create, #create, #instance?, #iterable?, #iterable_type, #kind_of_callable?, #loader, #name, new_function, #new_function, #really_instance?, #roundtrip_with_string?, #simple_name, simple_name, #to_alias_expanded_s, #to_s

Methods inherited from TypedModelObject

_pcore_type, create_ptype, register_ptypes

Methods included from PuppetObject

#_pcore_all_contents, #_pcore_contents, #_pcore_init_hash, #_pcore_type, #to_s

Constructor Details

#initialize(type) ⇒ PTypeWithContainedType

Returns a new instance of PTypeWithContainedType


421
422
423
# File 'lib/puppet/pops/types/types.rb', line 421

def initialize(type)
  @type = type
end

Instance Attribute Details

#typeObject (readonly)


419
420
421
# File 'lib/puppet/pops/types/types.rb', line 419

def type
  @type
end

Class Method Details

.register_ptype(loader, ir) ⇒ Object


415
416
417
# File 'lib/puppet/pops/types/types.rb', line 415

def self.register_ptype(loader, ir)
  # Abstract type. It doesn't register anything
end

Instance Method Details

#accept(visitor, guard) ⇒ Object


425
426
427
428
# File 'lib/puppet/pops/types/types.rb', line 425

def accept(visitor, guard)
  super
  @type.accept(visitor, guard) unless @type.nil?
end

#eql?(o) ⇒ Boolean


452
453
454
# File 'lib/puppet/pops/types/types.rb', line 452

def eql?(o)
  self.class == o.class && @type == o.type
end

#generalizeObject


430
431
432
433
434
435
436
437
# File 'lib/puppet/pops/types/types.rb', line 430

def generalize
  if @type.nil?
    self.class::DEFAULT
  else
    ge_type = @type.generalize
    @type.equal?(ge_type) ? self : self.class.new(ge_type)
  end
end

#hashObject


448
449
450
# File 'lib/puppet/pops/types/types.rb', line 448

def hash
  self.class.hash ^ @type.hash
end

#normalize(guard = nil) ⇒ Object


439
440
441
442
443
444
445
446
# File 'lib/puppet/pops/types/types.rb', line 439

def normalize(guard = nil)
  if @type.nil?
    self.class::DEFAULT
  else
    ne_type = @type.normalize(guard)
    @type.equal?(ne_type) ? self : self.class.new(ne_type)
  end
end

#resolve(loader) ⇒ Object


456
457
458
459
460
# File 'lib/puppet/pops/types/types.rb', line 456

def resolve(loader)
  rtype = @type
  rtype = rtype.resolve(loader) unless rtype.nil?
  rtype.equal?(@type) ? self : self.class.new(rtype)
end