Class: Puppet::Transaction::Event
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
Class Method Summary
collapse
Instance Method Summary
collapse
#clear_deprecation_warnings, #deprecation_warning
#tag, #tagged?, #tags
Constructor Details
#initialize(options = {}) ⇒ Event
Returns a new instance of Event.
25
26
27
28
29
30
|
# File 'lib/puppet/transaction/event.rb', line 25
def initialize(options = {})
@audited = false
options.each { |attr, value| send(attr.to_s + "=", value) }
@time = Time.now
end
|
Instance Attribute Details
#default_log_level ⇒ Object
Returns the value of attribute default_log_level.
15
16
17
|
# File 'lib/puppet/transaction/event.rb', line 15
def default_log_level
@default_log_level
end
|
13
14
15
|
# File 'lib/puppet/transaction/event.rb', line 13
def tags=(value)
@tags = value
end
|
Returns the value of attribute time.
14
15
16
|
# File 'lib/puppet/transaction/event.rb', line 14
def time
@time
end
|
Class Method Details
.from_pson(data) ⇒ Object
19
20
21
22
23
|
# File 'lib/puppet/transaction/event.rb', line 19
def self.from_pson(data)
obj = self.allocate
obj.initialize_from_hash(data)
obj
end
|
Instance Method Details
#initialize_from_hash(data) ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/puppet/transaction/event.rb', line 32
def initialize_from_hash(data)
@audited = data['audited']
@property = data['property']
@previous_value = data['previous_value']
@desired_value = data['desired_value']
@historical_value = data['historical_value']
@message = data['message']
@name = data['name'].intern
@status = data['status']
@time = data['time']
@time = Time.parse(@time) if @time.is_a? String
end
|
#property=(prop) ⇒ Object
45
46
47
|
# File 'lib/puppet/transaction/event.rb', line 45
def property=(prop)
@property = prop.to_s
end
|
#resource=(res) ⇒ Object
49
50
51
52
53
54
|
# File 'lib/puppet/transaction/event.rb', line 49
def resource=(res)
if res.respond_to?(:[]) and level = res[:loglevel]
@default_log_level = level
end
@resource = res.to_s
end
|
56
57
58
|
# File 'lib/puppet/transaction/event.rb', line 56
def send_log
super(log_level, message)
end
|
#status=(value) ⇒ Object
60
61
62
63
|
# File 'lib/puppet/transaction/event.rb', line 60
def status=(value)
raise ArgumentError, "Event status can only be #{EVENT_STATUSES.join(', ')}" unless EVENT_STATUSES.include?(value)
@status = value
end
|
65
66
67
|
# File 'lib/puppet/transaction/event.rb', line 65
def to_s
message
end
|
#to_yaml_properties ⇒ Object
69
70
71
|
# File 'lib/puppet/transaction/event.rb', line 69
def to_yaml_properties
YAML_ATTRIBUTES & instance_variables
end
|