Class: Puppet::Transaction::Event

Inherits:
Object
  • Object
show all
Includes:
Util::Logging, Util::Tagging
Defined in:
lib/vendor/puppet/transaction/event.rb

Overview

A simple struct for storing what happens on the system.

Constant Summary collapse

ATTRIBUTES =
[:name, :resource, :property, :previous_value, :desired_value, :historical_value, :status, :message, :file, :line, :source_description, :audited]
YAML_ATTRIBUTES =
%w{@audited @property @previous_value @desired_value @historical_value @message @name @status @time}
EVENT_STATUSES =
%w{noop success failure audit}

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Util::Logging

#clear_deprecation_warnings, #deprecation_warning

Methods included from Util::Tagging

#tag, #tagged?, #tags

Constructor Details

#initialize(options = {}) ⇒ Event

Returns a new instance of Event.



19
20
21
22
23
24
# File 'lib/vendor/puppet/transaction/event.rb', line 19

def initialize(options = {})
  @audited = false
  options.each { |attr, value| send(attr.to_s + "=", value) }

  @time = Time.now
end

Instance Attribute Details

#default_log_levelObject (readonly)

Returns the value of attribute default_log_level.



15
16
17
# File 'lib/vendor/puppet/transaction/event.rb', line 15

def default_log_level
  @default_log_level
end

#tags=(value) ⇒ Object (writeonly)

Sets the attribute tags

Parameters:

  • value

    the value to set the attribute tags to.



13
14
15
# File 'lib/vendor/puppet/transaction/event.rb', line 13

def tags=(value)
  @tags = value
end

#timeObject

Returns the value of attribute time.



14
15
16
# File 'lib/vendor/puppet/transaction/event.rb', line 14

def time
  @time
end

Instance Method Details

#property=(prop) ⇒ Object



26
27
28
# File 'lib/vendor/puppet/transaction/event.rb', line 26

def property=(prop)
  @property = prop.to_s
end

#resource=(res) ⇒ Object



30
31
32
33
34
35
# File 'lib/vendor/puppet/transaction/event.rb', line 30

def resource=(res)
  if res.respond_to?(:[]) and level = res[:loglevel]
    @default_log_level = level
  end
  @resource = res.to_s
end

#send_logObject



37
38
39
# File 'lib/vendor/puppet/transaction/event.rb', line 37

def send_log
  super(log_level, message)
end

#status=(value) ⇒ Object

Raises:

  • (ArgumentError)


41
42
43
44
# File 'lib/vendor/puppet/transaction/event.rb', line 41

def status=(value)
  raise ArgumentError, "Event status can only be #{EVENT_STATUSES.join(', ')}" unless EVENT_STATUSES.include?(value)
  @status = value
end

#to_sObject



46
47
48
# File 'lib/vendor/puppet/transaction/event.rb', line 46

def to_s
  message
end

#to_yaml_propertiesObject



50
51
52
# File 'lib/vendor/puppet/transaction/event.rb', line 50

def to_yaml_properties
  YAML_ATTRIBUTES & instance_variables
end