Class: Puppet::Util::Log::Destination

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet/util/log/destination.rb

Overview

A type of log destination.

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/puppet/util/log/destination.rb', line 4

def name
  @name
end

Class Method Details

.initvarsObject



7
8
9
# File 'lib/puppet/util/log/destination.rb', line 7

def self.initvars
  @matches = []
end

.match(obj) ⇒ Object

Mark the things we’re supposed to match.



12
13
14
15
# File 'lib/puppet/util/log/destination.rb', line 12

def self.match(obj)
  @matches ||= []
  @matches << obj
end

.match?(obj) ⇒ Boolean

See whether we match a given thing.

Returns:

  • (Boolean)


18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/puppet/util/log/destination.rb', line 18

def self.match?(obj)
  # Convert single-word strings into symbols like :console and :syslog
  if obj.is_a? String and obj =~ /^\w+$/
    obj = obj.downcase.intern
  end

  @matches.each do |thing|
    # Search for direct matches or class matches
    return true if thing === obj or thing == obj.class.to_s
  end
  false
end

.sethandler(&block) ⇒ Object

Set how to handle a message.



40
41
42
# File 'lib/puppet/util/log/destination.rb', line 40

def self.sethandler(&block)
  define_method(:handle, &block)
end

.setinit(&block) ⇒ Object

Mark how to initialize our object.



45
46
47
# File 'lib/puppet/util/log/destination.rb', line 45

def self.setinit(&block)
  define_method(:initialize, &block)
end

Instance Method Details

#nameObject



31
32
33
34
35
36
37
# File 'lib/puppet/util/log/destination.rb', line 31

def name
  if defined?(@name)
    return @name
  else
    return self.class.name
  end
end