Class: Puppet::Indirector::Face

Inherits:
Face
  • Object
show all
Defined in:
lib/vendor/puppet/indirector/face.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#fromObject

Returns the value of attribute from.



108
109
110
# File 'lib/vendor/puppet/indirector/face.rb', line 108

def from
  @from
end

Class Method Details

.indirectionsObject



32
33
34
# File 'lib/vendor/puppet/indirector/face.rb', line 32

def self.indirections
  Puppet::Indirector::Indirection.instances.collect { |t| t.to_s }.sort
end

.terminus_classes(indirection) ⇒ Object



36
37
38
# File 'lib/vendor/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

Instance Method Details

#call_indirection_method(method, key, options) ⇒ Object



40
41
42
43
44
45
46
47
48
49
# File 'lib/vendor/puppet/indirector/face.rb', line 40

def call_indirection_method(method, key, options)
  begin
    result = indirection.__send__(method, key, options)
  rescue => detail
    puts detail.backtrace if Puppet[:trace]
    raise "Could not call '#{method}' on '#{indirection_name}': #{detail}"
  end

  return result
end

#indirectionObject

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



122
123
124
125
126
127
128
# File 'lib/vendor/puppet/indirector/face.rb', line 122

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_nameObject



110
111
112
# File 'lib/vendor/puppet/indirector/face.rb', line 110

def indirection_name
  @indirection_name || name.to_sym
end

#set_indirection_name(name) ⇒ Object

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



116
117
118
# File 'lib/vendor/puppet/indirector/face.rb', line 116

def set_indirection_name(name)
  @indirection_name = name
end

#set_terminus(from) ⇒ Object



130
131
132
133
134
135
136
# File 'lib/vendor/puppet/indirector/face.rb', line 130

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