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

API:

  • public

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, #create, #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.

API:

  • public



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

def initialize(type)
  @type = type
end

Instance Attribute Details

#typeObject (readonly)

API:

  • public



380
381
382
# File 'lib/puppet/pops/types/types.rb', line 380

def type
  @type
end

Class Method Details

.register_ptype(loader, ir) ⇒ Object

API:

  • public



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

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

Instance Method Details

#accept(visitor, guard) ⇒ Object

API:

  • public



386
387
388
389
# File 'lib/puppet/pops/types/types.rb', line 386

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

#eql?(o) ⇒ Boolean

Returns:

API:

  • public



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

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

#generalizeObject

API:

  • public



391
392
393
394
395
396
397
398
# File 'lib/puppet/pops/types/types.rb', line 391

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

API:

  • public



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

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

#normalize(guard = nil) ⇒ Object

API:

  • public



400
401
402
403
404
405
406
407
# File 'lib/puppet/pops/types/types.rb', line 400

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

API:

  • public



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

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