class Puppet::Runtime

Provides access to runtime implementations.

@api private

Public Class Methods

new() click to toggle source
   # File lib/puppet/runtime.rb
10 def initialize
11   @runtime_services = {
12     http: proc do
13       klass = Puppet::Network::HttpPool.http_client_class
14       if klass == Puppet::Network::HTTP::Connection
15         Puppet::HTTP::Client.new
16       else
17         Puppet::HTTP::ExternalClient.new(klass)
18       end
19     end
20   }
21 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
29 def [](name)
30   service = @runtime_services[name]
31   raise ArgumentError, "Unknown service #{name}" unless service
32 
33   if service.is_a?(Proc)
34     @runtime_services[name] = service.call
35   else
36     service
37   end
38 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
45 def []=(name, impl)
46   @runtime_services[name] = impl
47 end
clear() click to toggle source

Clears all implementations. This is used for testing.

@api private

   # File lib/puppet/runtime.rb
52 def clear
53   initialize
54 end