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?, #check_self_recursion, #instance?, #iterable?, #iterable_type, #kind_of_callable?, #name, new_function, #new_function, #really_instance?, #simple_name, simple_name, #to_alias_expanded_s, #to_s

Methods inherited from TypedModelObject

_ptype, create_ptype, register_ptypes

Methods included from PuppetObject

#_ptype

Constructor Details

#initialize(type) ⇒ PTypeWithContainedType

Returns a new instance of PTypeWithContainedType.



378
379
380
# File 'lib/puppet/pops/types/types.rb', line 378

def initialize(type)
  @type = type
end

Instance Attribute Details

#typeObject (readonly)



376
377
378
# File 'lib/puppet/pops/types/types.rb', line 376

def type
  @type
end

Class Method Details

.register_ptype(loader, ir) ⇒ Object



372
373
374
# File 'lib/puppet/pops/types/types.rb', line 372

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

Instance Method Details

#accept(visitor, guard) ⇒ Object



382
383
384
385
# File 'lib/puppet/pops/types/types.rb', line 382

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

#eql?(o) ⇒ Boolean

Returns:

  • (Boolean)


409
410
411
# File 'lib/puppet/pops/types/types.rb', line 409

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

#generalizeObject



387
388
389
390
391
392
393
394
# File 'lib/puppet/pops/types/types.rb', line 387

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



405
406
407
# File 'lib/puppet/pops/types/types.rb', line 405

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

#normalize(guard = nil) ⇒ Object



396
397
398
399
400
401
402
403
# File 'lib/puppet/pops/types/types.rb', line 396

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(type_parser, loader) ⇒ Object



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

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