Method: Puppet::Pops::Types::PTypeSetType#name_for

Defined in:
lib/puppet/pops/types/p_type_set_type.rb

#name_for(t, default_name) ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the name by which the given type is referenced from within this type set

Parameters:

Returns:

  • (String)

    the name by which the type is referenced within this type set



231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
# File 'lib/puppet/pops/types/p_type_set_type.rb', line 231

def name_for(t, default_name)
  key = @types.key(t)
  if key.nil?
    if @references.empty?
      default_name
    else
      @references.each_pair do |ref_key, ref|
        ref_name = ref.type_set.name_for(t, nil)
        return "#{ref_key}::#{ref_name}" unless ref_name.nil?
      end
      default_name
    end
  else
    key
  end
end