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.


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

def initialize(type)
  @type = type
end

Instance Attribute Details

#typeObject (readonly)


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

def type
  @type
end

Class Method Details

.register_ptype(loader, ir) ⇒ Object


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

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

Instance Method Details

#accept(visitor, guard) ⇒ Object


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

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

#eql?(o) ⇒ Boolean

Returns:

  • (Boolean)

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

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

#generalizeObject


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

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


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

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

#normalize(guard = nil) ⇒ Object


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

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


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

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