1
# Manage indirections to termini. They are organized in terms of indirections -
2
# - e.g., configuration, node, file, certificate -- and each indirection has one
3
# or more terminus types defined. The indirection is configured via the
4
# +indirects+ method, which will be called by the class extending itself
6
module Puppet::Indirector
7
# LAK:FIXME We need to figure out how to handle documentation for the
8
# different indirection types.
10
require 'puppet/indirector/indirection'
11
require 'puppet/indirector/terminus'
12
require 'puppet/indirector/envelope'
14
# Declare that the including class indirects its methods to
15
# this terminus. The terminus name must be the name of a Puppet
16
# default, not the value -- if it's the value, then it gets
17
# evaluated at parse time, which is before the user has had a chance
19
def indirects(indirection, options = {})
20
raise(ArgumentError, "Already handling indirection for %s; cannot also handle %s" % [@indirection.name, indirection]) if defined?(@indirection) and @indirection
21
# populate this class with the various new methods
23
include InstanceMethods
24
include Puppet::Indirector::Envelope
26
# instantiate the actual Terminus for that type and this name (:ldap, w/ args :node)
27
# & hook the instantiated Terminus into this class (Node: @indirection = terminus)
28
@indirection = Puppet::Indirector::Indirection.new(self, indirection, options)
33
attr_reader :indirection
35
def cache_class=(klass)
36
indirection.cache_class = klass
39
def terminus_class=(klass)
40
indirection.terminus_class = klass
43
# Expire any cached instance.
45
indirection.expire *args
49
indirection.find *args
53
indirection.destroy *args
57
indirection.search *args
61
module InstanceMethods
63
self.class.indirection.save self, *args