class Puppet::Indirector::Face

Attributes

from[RW]

Public Class Methods

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

Public Instance Methods

call_indirection_method(method, key, options) click to toggle source
# File lib/puppet/indirector/face.rb, line 40
def call_indirection_method(method, key, options)
  begin
    result = indirection.__send__(method, key, options)
  rescue => detail
    message = "Could not call '#{method}' on '#{indirection_name}': #{detail}"
    Puppet.log_exception(detail, message)
    raise message
  end

  return result
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, line 123
def indirection
  unless @indirection
    @indirection = Puppet::Indirector::Indirection.instance(indirection_name)
    @indirection or raise "Could not find terminus for #{indirection_name}"
  end
  @indirection
end
indirection_name() click to toggle source
# File lib/puppet/indirector/face.rb, line 111
def indirection_name
  @indirection_name || name.to_sym
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, line 117
def set_indirection_name(name)
  @indirection_name = name
end
set_terminus(from) click to toggle source
# File lib/puppet/indirector/face.rb, line 131
def set_terminus(from)
  begin
    indirection.terminus_class = from
  rescue => detail
    raise "Could not set '#{indirection.name}' terminus to '#{from}' (#{detail}); valid terminus types are #{self.class.terminus_classes(indirection.name).join(", ") }"
  end
end