class Puppet::Pops::Loader::TypedName

A namespace/name/type combination that can be used as a compound hash key

@api public

Attributes

compound_name[R]
hash[R]
name[R]
name_authority[R]
name_parts[R]
type[R]

Public Class Methods

new(type, name, name_authority = Pcore::RUNTIME_NAME_AUTHORITY) click to toggle source
   # File lib/puppet/pops/loader/typed_name.rb
15 def initialize(type, name, name_authority = Pcore::RUNTIME_NAME_AUTHORITY)
16   name = name.downcase
17   @type = type
18   @name_authority = name_authority
19   # relativize the name (get rid of leading ::), and make the split string available
20   parts = name.to_s.split(DOUBLE_COLON)
21   if parts[0].empty?
22     parts.shift
23     @name = name[2..-1]
24   else
25     @name = name
26   end
27   @name_parts = parts.freeze
28 
29   # Use a frozen compound key for the hash and comparison. Most varying part first
30   @compound_name = "#{@name}/#{@type}/#{@name_authority}"
31   @hash = @compound_name.hash
32   freeze
33 end

Public Instance Methods

==(o) click to toggle source
   # File lib/puppet/pops/loader/typed_name.rb
35 def ==(o)
36   o.class == self.class && o.compound_name == @compound_name
37 end
Also aliased as: eql?
eql?(o)
Alias for: ==
parent() click to toggle source

@return the parent of this instance, or nil if this instance is not qualified

   # File lib/puppet/pops/loader/typed_name.rb
42 def parent
43   @name_parts.size > 1 ? self.class.new(@type, @name_parts[0...-1].join(DOUBLE_COLON), @name_authority) : nil
44 end
qualified?() click to toggle source
   # File lib/puppet/pops/loader/typed_name.rb
46 def qualified?
47   @name_parts.size > 1
48 end
to_s() click to toggle source
   # File lib/puppet/pops/loader/typed_name.rb
50 def to_s
51   "#{@name_authority}/#{@type}/#{@name}"
52 end