class Puppet::Pops::Types::PStructElement

@api public

@api public

Attributes

key_type[RW]
value_type[RW]

Public Class Methods

new(key_type, value_type) click to toggle source
     # File lib/puppet/pops/types/types.rb
1944 def initialize(key_type, value_type)
1945   @key_type = key_type
1946   @value_type = value_type
1947 end
register_ptype(loader, ir) click to toggle source
     # File lib/puppet/pops/types/types.rb
1921 def self.register_ptype(loader, ir)
1922   @type = Pcore::create_object_type(loader, ir, self, 'Pcore::StructElement'.freeze, nil,
1923     'key_type' => PTypeType::DEFAULT,
1924     'value_type' => PTypeType::DEFAULT)
1925 end

Public Instance Methods

<=>(o) click to toggle source
     # File lib/puppet/pops/types/types.rb
1965 def <=>(o)
1966   self.name <=> o.name
1967 end
==(o) click to toggle source
     # File lib/puppet/pops/types/types.rb
1973 def ==(o)
1974   self.class == o.class && value_type == o.value_type && key_type == o.key_type
1975 end
accept(visitor, guard) click to toggle source
     # File lib/puppet/pops/types/types.rb
1929 def accept(visitor, guard)
1930   @key_type.accept(visitor, guard)
1931   @value_type.accept(visitor, guard)
1932 end
eql?(o) click to toggle source
     # File lib/puppet/pops/types/types.rb
1969 def eql?(o)
1970   self == o
1971 end
generalize() click to toggle source
     # File lib/puppet/pops/types/types.rb
1949 def generalize
1950   gv_type = @value_type.generalize
1951   @value_type.equal?(gv_type) ? self : PStructElement.new(@key_type, gv_type)
1952 end
hash() click to toggle source
     # File lib/puppet/pops/types/types.rb
1934 def hash
1935   value_type.hash ^ key_type.hash
1936 end
name() click to toggle source
     # File lib/puppet/pops/types/types.rb
1938 def name
1939   k = key_type
1940   k = k.optional_type if k.is_a?(POptionalType)
1941   k.value
1942 end
normalize(guard = nil) click to toggle source
     # File lib/puppet/pops/types/types.rb
1954 def normalize(guard = nil)
1955   nv_type = @value_type.normalize(guard)
1956   @value_type.equal?(nv_type) ? self : PStructElement.new(@key_type, nv_type)
1957 end
replace_value_type(new_type) click to toggle source

Special boostrap method to overcome the hen and egg problem with the Object initializer that contains types that are derived from Object (such as Annotation)

@api private

     # File lib/puppet/pops/types/types.rb
1981 def replace_value_type(new_type)
1982   @value_type = new_type
1983 end
resolve(loader) click to toggle source
     # File lib/puppet/pops/types/types.rb
1959 def resolve(loader)
1960   rkey_type = @key_type.resolve(loader)
1961   rvalue_type = @value_type.resolve(loader)
1962   rkey_type.equal?(@key_type) && rvalue_type.equal?(@value_type) ? self : self.class.new(rkey_type, rvalue_type)
1963 end