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.



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

def initialize(type)
  @type = type
end

Instance Attribute Details

#typeObject (readonly)



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

def type
  @type
end

Class Method Details

.register_ptype(loader, ir) ⇒ Object



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

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

Instance Method Details

#accept(visitor, guard) ⇒ Object



427
428
429
430
# File 'lib/puppet/pops/types/types.rb', line 427

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

#eql?(o) ⇒ Boolean

Returns:

  • (Boolean)


454
455
456
# File 'lib/puppet/pops/types/types.rb', line 454

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

#generalizeObject



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

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



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

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

#normalize(guard = nil) ⇒ Object



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

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



458
459
460
461
462
# File 'lib/puppet/pops/types/types.rb', line 458

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