class Puppet::Indirector::Face

Attributes

from[RW]

Public Class Methods

indirections() click to toggle source
   # File lib/puppet/indirector/face.rb
32 def self.indirections
33   Puppet::Indirector::Indirection.instances.collect { |t| t.to_s }.sort
34 end
terminus_classes(indirection) click to toggle source
   # File lib/puppet/indirector/face.rb
36 def self.terminus_classes(indirection)
37   Puppet::Indirector::Terminus.terminus_classes(indirection.to_sym).collect { |t| t.to_s }.sort
38 end

Public Instance Methods

call_indirection_method(method, key, options) click to toggle source
   # File lib/puppet/indirector/face.rb
40 def call_indirection_method(method, key, options)
41   begin
42     if method == :save
43       # key is really the instance to save
44       result = indirection.__send__(method, key, nil, options)
45     else
46       result = indirection.__send__(method, key, options)
47     end
48   rescue => detail
49     message = _("Could not call '%{method}' on '%{indirection}': %{detail}") % { method: method, indirection: indirection_name, detail: detail }
50     Puppet.log_exception(detail, message)
51     raise RuntimeError, message, detail.backtrace
52   end
53 
54   return result
55 end
indirection() click to toggle source

Return an indirection associated with a face, if one exists; One usually does.

    # File lib/puppet/indirector/face.rb
137 def indirection
138   unless @indirection
139     @indirection = Puppet::Indirector::Indirection.instance(indirection_name)
140     @indirection or raise _("Could not find terminus for %{indirection}") % { indirection: indirection_name }
141   end
142   @indirection
143 end
indirection_name() click to toggle source
    # File lib/puppet/indirector/face.rb
125 def indirection_name
126   @indirection_name || name.to_sym
127 end
set_indirection_name(name) click to toggle source

Here's your opportunity to override the indirection name. By default it will be the same name as the face.

    # File lib/puppet/indirector/face.rb
131 def set_indirection_name(name)
132   @indirection_name = name
133 end
set_terminus(from) click to toggle source
    # File lib/puppet/indirector/face.rb
145 def set_terminus(from)
146   begin
147     indirection.terminus_class = from
148   rescue => detail
149     msg = _("Could not set '%{indirection}' terminus to '%{from}' (%{detail}); valid terminus types are %{types}") % { indirection: indirection.name, from: from, detail: detail, types: self.class.terminus_classes(indirection.name).join(", ") }
150     raise detail, msg, detail.backtrace
151   end
152 end