Class: Puppet::Pops::Types::TypeSetReference
- Includes:
- Annotatable
- Defined in:
- lib/puppet/pops/types/type_set_reference.rb
Constant Summary
Constants included from Annotatable
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#name_authority ⇒ Object
readonly
Returns the value of attribute name_authority.
-
#type_set ⇒ Object
readonly
Returns the value of attribute type_set.
-
#version_range ⇒ Object
readonly
Returns the value of attribute version_range.
Instance Method Summary collapse
- #_pcore_init_hash ⇒ Object
- #accept(visitor, guard) ⇒ Object
- #eql?(o) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(owner, init_hash) ⇒ TypeSetReference
constructor
A new instance of TypeSetReference.
- #resolve(loader) ⇒ Object
- #to_s ⇒ Object
Methods included from Annotatable
#annotatable_accept, #annotations, #init_annotatable
Constructor Details
#initialize(owner, init_hash) ⇒ TypeSetReference
Returns a new instance of TypeSetReference.
11 12 13 14 15 16 17 |
# File 'lib/puppet/pops/types/type_set_reference.rb', line 11 def initialize(owner, init_hash) @owner = owner @name_authority = (init_hash[KEY_NAME_AUTHORITY] || owner.).freeze @name = init_hash[KEY_NAME].freeze @version_range = PSemVerRangeType.convert(init_hash[KEY_VERSION_RANGE]) init_annotatable(init_hash) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/puppet/pops/types/type_set_reference.rb', line 7 def name @name end |
#name_authority ⇒ Object (readonly)
Returns the value of attribute name_authority.
6 7 8 |
# File 'lib/puppet/pops/types/type_set_reference.rb', line 6 def @name_authority end |
#type_set ⇒ Object (readonly)
Returns the value of attribute type_set.
9 10 11 |
# File 'lib/puppet/pops/types/type_set_reference.rb', line 9 def type_set @type_set end |
#version_range ⇒ Object (readonly)
Returns the value of attribute version_range.
8 9 10 |
# File 'lib/puppet/pops/types/type_set_reference.rb', line 8 def version_range @version_range end |
Instance Method Details
#_pcore_init_hash ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/puppet/pops/types/type_set_reference.rb', line 31 def _pcore_init_hash result = super result[KEY_NAME_AUTHORITY] = @name_authority unless @name_authority == @owner. result[KEY_NAME] = @name result[KEY_VERSION_RANGE] = @version_range.to_s result end |
#accept(visitor, guard) ⇒ Object
19 20 21 |
# File 'lib/puppet/pops/types/type_set_reference.rb', line 19 def accept(visitor, guard) annotatable_accept(visitor, guard) end |
#eql?(o) ⇒ Boolean
23 24 25 |
# File 'lib/puppet/pops/types/type_set_reference.rb', line 23 def eql?(o) self.class == o.class && @name_authority.eql?(o.) && @name.eql?(o.name) && @version_range.eql?(o.version_range) end |
#hash ⇒ Object
27 28 29 |
# File 'lib/puppet/pops/types/type_set_reference.rb', line 27 def hash [@name_authority, @name, @version_range].hash end |
#resolve(loader) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/puppet/pops/types/type_set_reference.rb', line 39 def resolve(loader) typed_name = Loader::TypedName.new(:type, @name, @name_authority) loaded_entry = loader.load_typed(typed_name) type_set = loaded_entry.nil? ? nil : loaded_entry.value raise ArgumentError, "#{self} cannot be resolved" if type_set.nil? raise ArgumentError, "#{self} resolves to a #{type_set.name}" unless type_set.is_a?(PTypeSetType) @type_set = type_set.resolve(loader) unless @version_range.include?(@type_set.version) raise ArgumentError, "#{self} resolves to an incompatible version. Expected #{@version_range}, got #{type_set.version}" end nil end |
#to_s ⇒ Object
54 55 56 |
# File 'lib/puppet/pops/types/type_set_reference.rb', line 54 def to_s "#{@owner.label} reference to TypeSet named '#{@name}'" end |