class Puppet::Pops::Loader::Loader::TypedName

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

Attributes

name[R]
name_parts[R]
qualified[R]

True if name is qualified (more than a single segment)

type[R]

Public Instance Methods

==(o) click to toggle source
# File lib/puppet/pops/loader/loader.rb, line 169
def ==(o)
  o.class == self.class && type == o.type && name == o.name
end
Also aliased as: eql?
eql?(o) click to toggle source
Alias for: ==
hash() click to toggle source
# File lib/puppet/pops/loader/loader.rb, line 165
def hash
  @hash
end
to_s() click to toggle source
# File lib/puppet/pops/loader/loader.rb, line 175
def to_s
  "#{type}/#{name}"
end

Public Class Methods

new(type, name) click to toggle source
# File lib/puppet/pops/loader/loader.rb, line 147
def initialize(type, name)
  @type = type
  # relativize the name (get rid of leading ::), and make the split string available
  @name_parts = name.to_s.split(/::/)
  @name_parts.shift if name_parts[0].empty?
  @name = name_parts.join('::')
  @qualified = name_parts.size > 1
  # precompute hash - the name is frozen, so this is safe to do
  @hash = [self.class, type, @name].hash

  # Not allowed to have numeric names - 0, 010, 0x10, 1.2 etc
  if Puppet::Pops::Utils.is_numeric?(@name)
    raise ArgumentError, "Illegal attempt to use a numeric name '#{name}' at #{origin_label(origin)}."
  end

  freeze()
end