module Puppet::Indirector

Manage indirections to termini. They are organized in terms of indirections -

or more terminus types defined. The indirection is configured via the indirects method, which will be called by the class extending itself with this module.

Constants

BadNameRegexp

Helper definition for indirections that handle filenames.

Public Class Methods

configure_routes(application_routes) click to toggle source
   # File lib/puppet/indirector.rb
16 def self.configure_routes(application_routes)
17   application_routes.each do |indirection_name, termini|
18     indirection_name = indirection_name.to_sym
19     terminus_name = termini["terminus"]
20     cache_name    = termini["cache"]
21 
22     Puppet::Indirector::Terminus.terminus_class(indirection_name, terminus_name || cache_name)
23 
24     indirection = Puppet::Indirector::Indirection.instance(indirection_name)
25     raise _("Indirection %{indirection_name} does not exist") % { indirection_name: indirection_name } unless indirection
26 
27     indirection.set_global_setting(:terminus_class, terminus_name) if terminus_name
28     indirection.set_global_setting(:cache_class, cache_name) if cache_name
29   end
30 end

Public Instance Methods

indirects(indirection, options = {}) click to toggle source

Declare that the including class indirects its methods to this terminus. The terminus name must be the name of a Puppet default, not the value – if it's the value, then it gets evaluated at parse time, which is before the user has had a chance to override it.

   # File lib/puppet/indirector.rb
37 def indirects(indirection, options = {})
38   raise(ArgumentError, _("Already handling indirection for %{current}; cannot also handle %{next}") % { current: @indirection.name, next: indirection }) if @indirection
39   # populate this class with the various new methods
40   extend ClassMethods
41   include Puppet::Indirector::Envelope
42   include Puppet::Network::FormatSupport
43 
44   # record the indirected class name for documentation purposes
45   options[:indirected_class] = name
46 
47   # instantiate the actual Terminus for that type and this name (:ldap, w/ args :node)
48   # & hook the instantiated Terminus into this class (Node: @indirection = terminus)
49   @indirection = Puppet::Indirector::Indirection.new(self, indirection, **options)
50 end