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
Constructor Details
#initialize(key_type, value_type) ⇒ PStructElement
Returns a new instance of PStructElement.
1761
1762
1763
1764
|
# File 'lib/puppet/pops/types/types.rb', line 1761
def initialize(key_type, value_type)
@key_type = key_type
@value_type = value_type
end
|
Instance Attribute Details
1744
1745
1746
|
# File 'lib/puppet/pops/types/types.rb', line 1744
def key_type
@key_type
end
|
#value_type ⇒ Object
1744
1745
1746
|
# File 'lib/puppet/pops/types/types.rb', line 1744
def value_type
@value_type
end
|
Class Method Details
.register_ptype(loader, ir) ⇒ Object
1738
1739
1740
1741
1742
|
# File 'lib/puppet/pops/types/types.rb', line 1738
def self.register_ptype(loader, ir)
@type = Pcore::create_object_type(loader, ir, self, 'Pcore::StructElement'.freeze, nil,
'key_type' => PType::DEFAULT,
'value_type' => PType::DEFAULT)
end
|
Instance Method Details
1784
1785
1786
|
# File 'lib/puppet/pops/types/types.rb', line 1784
def <=>(o)
self.name <=> o.name
end
|
1792
1793
1794
|
# File 'lib/puppet/pops/types/types.rb', line 1792
def ==(o)
self.class == o.class && value_type == o.value_type && key_type == o.key_type
end
|
#accept(visitor, guard) ⇒ Object
1746
1747
1748
1749
|
# File 'lib/puppet/pops/types/types.rb', line 1746
def accept(visitor, guard)
@key_type.accept(visitor, guard)
@value_type.accept(visitor, guard)
end
|
#eql?(o) ⇒ Boolean
1788
1789
1790
|
# File 'lib/puppet/pops/types/types.rb', line 1788
def eql?(o)
self == o
end
|
#generalize ⇒ Object
1766
1767
1768
1769
|
# File 'lib/puppet/pops/types/types.rb', line 1766
def generalize
gv_type = @value_type.generalize
@value_type.equal?(gv_type) ? self : PStructElement.new(@key_type, gv_type)
end
|
1751
1752
1753
|
# File 'lib/puppet/pops/types/types.rb', line 1751
def hash
value_type.hash ^ key_type.hash
end
|
1755
1756
1757
1758
1759
|
# File 'lib/puppet/pops/types/types.rb', line 1755
def name
k = key_type
k = k.optional_type if k.is_a?(POptionalType)
k.value
end
|
#normalize(guard = nil) ⇒ Object
1771
1772
1773
1774
|
# File 'lib/puppet/pops/types/types.rb', line 1771
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)
1800
1801
1802
|
# File 'lib/puppet/pops/types/types.rb', line 1800
def replace_value_type(new_type)
@value_type = new_type
end
|
#resolve(type_parser, loader) ⇒ Object
1776
1777
1778
1779
1780
1781
1782
|
# File 'lib/puppet/pops/types/types.rb', line 1776
def resolve(type_parser, loader)
rkey_type = @key_type
rkey_type = rkey_type.resolve(type_parser, loader) unless rkey_type.nil?
rvalue_type = @value_type
rvalue_type = rvalue_type.resolve(type_parser, loader) unless rvalue_type.nil?
rkey_type.equal?(@key_type) && rvalue_type.equal?(@value_type) ? self : self.class.new(rkey_type, rvalue_type)
end
|