Class: Puppet::Pops::Types::PStructElement
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
_pcore_type, create_ptype, register_ptypes
#_pcore_all_contents, #_pcore_contents, #_pcore_init_hash, #_pcore_type, #to_s
Constructor Details
#initialize(key_type, value_type) ⇒ PStructElement
Returns a new instance of PStructElement.
1942
1943
1944
1945
|
# File 'lib/puppet/pops/types/types.rb', line 1942
def initialize(key_type, value_type)
@key_type = key_type
@value_type = value_type
end
|
Instance Attribute Details
1925
1926
1927
|
# File 'lib/puppet/pops/types/types.rb', line 1925
def key_type
@key_type
end
|
#value_type ⇒ Object
1925
1926
1927
|
# File 'lib/puppet/pops/types/types.rb', line 1925
def value_type
@value_type
end
|
Class Method Details
.register_ptype(loader, ir) ⇒ Object
Instance Method Details
1963
1964
1965
|
# File 'lib/puppet/pops/types/types.rb', line 1963
def <=>(o)
self.name <=> o.name
end
|
1971
1972
1973
|
# File 'lib/puppet/pops/types/types.rb', line 1971
def ==(o)
self.class == o.class && value_type == o.value_type && key_type == o.key_type
end
|
#accept(visitor, guard) ⇒ Object
1927
1928
1929
1930
|
# File 'lib/puppet/pops/types/types.rb', line 1927
def accept(visitor, guard)
@key_type.accept(visitor, guard)
@value_type.accept(visitor, guard)
end
|
#eql?(o) ⇒ Boolean
1967
1968
1969
|
# File 'lib/puppet/pops/types/types.rb', line 1967
def eql?(o)
self == o
end
|
#generalize ⇒ Object
1947
1948
1949
1950
|
# File 'lib/puppet/pops/types/types.rb', line 1947
def generalize
gv_type = @value_type.generalize
@value_type.equal?(gv_type) ? self : PStructElement.new(@key_type, gv_type)
end
|
1932
1933
1934
|
# File 'lib/puppet/pops/types/types.rb', line 1932
def hash
value_type.hash ^ key_type.hash
end
|
1936
1937
1938
1939
1940
|
# File 'lib/puppet/pops/types/types.rb', line 1936
def name
k = key_type
k = k.optional_type if k.is_a?(POptionalType)
k.value
end
|
#normalize(guard = nil) ⇒ Object
1952
1953
1954
1955
|
# File 'lib/puppet/pops/types/types.rb', line 1952
def normalize(guard = nil)
nv_type = @value_type.normalize(guard)
@value_type.equal?(nv_type) ? self : PStructElement.new(@key_type, nv_type)
end
|
#replace_value_type(new_type) ⇒ Object
This method is part of a private API.
You should avoid using this method if possible, as it may be removed or be changed in the future.
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)
1979
1980
1981
|
# File 'lib/puppet/pops/types/types.rb', line 1979
def replace_value_type(new_type)
@value_type = new_type
end
|
#resolve(loader) ⇒ Object
1957
1958
1959
1960
1961
|
# File 'lib/puppet/pops/types/types.rb', line 1957
def resolve(loader)
rkey_type = @key_type.resolve(loader)
rvalue_type = @value_type.resolve(loader)
rkey_type.equal?(@key_type) && rvalue_type.equal?(@value_type) ? self : self.class.new(rkey_type, rvalue_type)
end
|