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.



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

def name
  @name
end

Class Method Details

.initvarsObject



9
10
11
# File 'lib/puppet/util/log/destination.rb', line 9

def self.initvars
  @matches = []
end

.match(obj) ⇒ Object

Mark the things we’re supposed to match.



14
15
16
17
# File 'lib/puppet/util/log/destination.rb', line 14

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

.match?(obj) ⇒ Boolean

See whether we match a given thing.

Returns:

  • (Boolean)


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

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.



42
43
44
# File 'lib/puppet/util/log/destination.rb', line 42

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

.setinit(&block) ⇒ Object

Mark how to initialize our object.



47
48
49
# File 'lib/puppet/util/log/destination.rb', line 47

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

Instance Method Details

#nameObject



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

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