class Puppet::Runtime

Provides access to runtime implementations.

@api private

Public Class Methods

new() click to toggle source
   # File lib/puppet/runtime.rb
12 def initialize
13   @runtime_services = {
14     http: proc do
15       klass = Puppet::Network::HttpPool.http_client_class
16       if klass == Puppet::Network::HTTP::Connection
17         Puppet::HTTP::Client.new
18       else
19         Puppet::HTTP::ExternalClient.new(klass)
20       end
21     end,
22     facter: proc { Puppet::FacterImpl.new }
23   }
24 end

Public Instance Methods

[](name) click to toggle source

Get a runtime implementation.

@param name [Symbol] the name of the implementation @return [Object] the runtime implementation @api private

   # File lib/puppet/runtime.rb
40 def [](name)
41   service = @runtime_services[name]
42   raise ArgumentError, "Unknown service #{name}" unless service
43 
44   if service.is_a?(Proc)
45     @runtime_services[name] = service.call
46   else
47     service
48   end
49 end
[]=(name, impl) click to toggle source

Register a runtime implementation.

@param name [Symbol] the name of the implementation @param impl [Object] the runtime implementation @api private

   # File lib/puppet/runtime.rb
56 def []=(name, impl)
57   @runtime_services[name] = impl
58 end
clear() click to toggle source

Clears all implementations. This is used for testing.

@api private

   # File lib/puppet/runtime.rb
63 def clear
64   initialize
65 end
load_services() click to toggle source

Loads all runtime implementations.

@return Array the names of loaded implementations @api private

   # File lib/puppet/runtime.rb
31 def load_services
32   @runtime_services.keys.each { |key| self[key] }
33 end