Class: Puppet::Pops::Types::ClassLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet/pops/types/class_loader.rb

Overview

This means it can load a class from a gem, or from puppet modules.

Class Method Summary collapse

Class Method Details

.provide(name) ⇒ Class?

Returns a Class given a fully qualified class name. Lookup of class is never relative to the calling namespace.

Parameters:

  • name (String, Array<String>, Array<Symbol>, PAnyType)

    A fully qualified class name String (e.g. ‘::Foo::Bar’, ‘Foo::Bar’), a PAnyType, or a fully qualified name in Array form where each part is either a String or a Symbol, e.g. ‘%wPuppetlabs SomeExtension`.

Returns:

  • (Class, nil)

    the looked up class or nil if no such class is loaded

Raises:

  • ArgumentError If the given argument has the wrong type



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/puppet/pops/types/class_loader.rb', line 21

def self.provide(name)
  case name
  when String
    provide_from_string(name)

  when Array
    provide_from_name_path(name.join('::'), name)

  when PAnyType, PType
    provide_from_type(name)

  else
    raise ArgumentError, "Cannot provide a class from a '#{name.class.name}'"
  end
end