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_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 14 def initialize(type, name, name_authority = Pcore::RUNTIME_NAME_AUTHORITY) 15 name = name.downcase 16 @type = type 17 @name_authority = name_authority 18 # relativize the name (get rid of leading ::), and make the split string available 19 parts = name.to_s.split(DOUBLE_COLON) 20 if parts[0].empty? 21 parts.shift 22 @name = name[2..-1] 23 else 24 @name = name 25 end 26 @name_parts = parts.freeze 27 28 # Use a frozen compound key for the hash and comparison. Most varying part first 29 @compound_name = "#{@name}/#{@type}/#{@name_authority}".freeze 30 @hash = @compound_name.hash 31 freeze 32 end
Public Instance Methods
==(o)
click to toggle source
# File lib/puppet/pops/loader/typed_name.rb 34 def ==(o) 35 o.class == self.class && o.compound_name == @compound_name 36 end
Also aliased as: eql?
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 41 def parent 42 @name_parts.size > 1 ? self.class.new(@type, @name_parts[0...-1].join(DOUBLE_COLON), @name_authority) : nil 43 end
qualified?()
click to toggle source
# File lib/puppet/pops/loader/typed_name.rb 45 def qualified? 46 @name_parts.size > 1 47 end
to_s()
click to toggle source
# File lib/puppet/pops/loader/typed_name.rb 49 def to_s 50 "#{@name_authority}/#{@type}/#{@name}" 51 end