class Puppet::Pops::Types::TypeSetReference

Attributes

name[R]
name_authority[R]
type_set[R]
version_range[R]

Public Class Methods

new(owner, init_hash) click to toggle source
   # File lib/puppet/pops/types/type_set_reference.rb
11 def initialize(owner, init_hash)
12   @owner = owner
13   @name_authority = (init_hash[KEY_NAME_AUTHORITY] || owner.name_authority).freeze
14   @name = init_hash[KEY_NAME].freeze
15   @version_range = PSemVerRangeType.convert(init_hash[KEY_VERSION_RANGE])
16   init_annotatable(init_hash)
17 end

Public Instance Methods

_pcore_init_hash() click to toggle source
Calls superclass method Puppet::Pops::Types::Annotatable#_pcore_init_hash
   # File lib/puppet/pops/types/type_set_reference.rb
31 def _pcore_init_hash
32   result = super
33   result[KEY_NAME_AUTHORITY] = @name_authority unless @name_authority == @owner.name_authority
34   result[KEY_NAME] = @name
35   result[KEY_VERSION_RANGE] = @version_range.to_s
36   result
37 end
accept(visitor, guard) click to toggle source
   # File lib/puppet/pops/types/type_set_reference.rb
19 def accept(visitor, guard)
20   annotatable_accept(visitor, guard)
21 end
eql?(o) click to toggle source
   # File lib/puppet/pops/types/type_set_reference.rb
23 def eql?(o)
24   self.class == o.class && @name_authority.eql?(o.name_authority) && @name.eql?(o.name) && @version_range.eql?(o.version_range)
25 end
hash() click to toggle source
   # File lib/puppet/pops/types/type_set_reference.rb
27 def hash
28   [@name_authority, @name, @version_range].hash
29 end
resolve(loader) click to toggle source
   # File lib/puppet/pops/types/type_set_reference.rb
39 def resolve(loader)
40   typed_name = Loader::TypedName.new(:type, @name, @name_authority)
41   loaded_entry = loader.load_typed(typed_name)
42   type_set = loaded_entry.nil? ? nil : loaded_entry.value
43 
44   raise ArgumentError, "#{self} cannot be resolved" if type_set.nil?
45   raise ArgumentError, "#{self} resolves to a #{type_set.name}" unless type_set.is_a?(PTypeSetType)
46 
47   @type_set = type_set.resolve(loader)
48   unless @version_range.include?(@type_set.version)
49     raise ArgumentError, "#{self} resolves to an incompatible version. Expected #{@version_range}, got #{type_set.version}"
50   end
51   nil
52 end
to_s() click to toggle source
   # File lib/puppet/pops/types/type_set_reference.rb
54 def to_s
55   "#{@owner.label} reference to TypeSet named '#{@name}'"
56 end