Class: Puppet::Transaction::Event Private
- Defined in:
- lib/puppet/transaction/event.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
A simple struct for storing what happens on the system.
Constant Summary collapse
- ATTRIBUTES =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
[:name, :resource, :property, :previous_value, :desired_value, :historical_value, :status, :message, :file, :line, :source_description, :audited, :invalidate_refreshes]
- YAML_ATTRIBUTES =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
%w{@audited @property @previous_value @desired_value @historical_value @message @name @status @time}.map(&:to_sym)
- EVENT_STATUSES =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
%w{noop success failure audit}
Instance Attribute Summary collapse
- #default_log_level ⇒ Object readonly private
- #time ⇒ Object private
Class Method Summary collapse
- .from_pson(data) ⇒ Object private
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Event
constructor
private
A new instance of Event.
- #initialize_from_hash(data) ⇒ Object private
- #property=(prop) ⇒ Object private
- #resource=(res) ⇒ Object private
- #send_log ⇒ Object private
- #status=(value) ⇒ Object private
- #to_data_hash ⇒ Object private
- #to_pson(*args) ⇒ Object private
- #to_s ⇒ Object private
- #to_yaml_properties ⇒ Object private
Methods included from Network::FormatSupport
included, #mime, #render, #support_format?, #to_msgpack
Methods included from Util::Logging
#clear_deprecation_warnings, #deprecation_warning, #format_exception, #get_deprecation_offender, #log_and_raise, #log_deprecations_to_file, #log_exception
Methods included from Util::Tagging
Methods included from Util::MethodHelper
#requiredopts, #set_options, #symbolize_options
Constructor Details
#initialize(options = {}) ⇒ Event
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Event.
28 29 30 31 32 33 |
# File 'lib/puppet/transaction/event.rb', line 28 def initialize( = {}) @audited = false () @time = Time.now end |
Instance Attribute Details
#default_log_level ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
18 19 20 |
# File 'lib/puppet/transaction/event.rb', line 18 def default_log_level @default_log_level end |
#time ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
17 18 19 |
# File 'lib/puppet/transaction/event.rb', line 17 def time @time end |
Class Method Details
.from_pson(data) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
22 23 24 25 26 |
# File 'lib/puppet/transaction/event.rb', line 22 def self.from_pson(data) obj = self.allocate obj.initialize_from_hash(data) obj end |
Instance Method Details
#initialize_from_hash(data) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/puppet/transaction/event.rb', line 35 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 if data['name'] @status = data['status'] @time = data['time'] @time = Time.parse(@time) if @time.is_a? String end |
#property=(prop) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
66 67 68 |
# File 'lib/puppet/transaction/event.rb', line 66 def property=(prop) @property = prop.to_s end |
#resource=(res) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
70 71 72 73 74 75 |
# File 'lib/puppet/transaction/event.rb', line 70 def resource=(res) if res.respond_to?(:[]) and level = res[:loglevel] @default_log_level = level end @resource = res.to_s end |
#send_log ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
77 78 79 |
# File 'lib/puppet/transaction/event.rb', line 77 def send_log super(log_level, ) end |
#status=(value) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
81 82 83 84 |
# File 'lib/puppet/transaction/event.rb', line 81 def status=(value) raise ArgumentError, "Event status can only be #{EVENT_STATUSES.join(', ')}" unless EVENT_STATUSES.include?(value) @status = value end |
#to_data_hash ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/puppet/transaction/event.rb', line 48 def to_data_hash { 'audited' => @audited, 'property' => @property, 'previous_value' => @previous_value, 'desired_value' => @desired_value, 'historical_value' => @historical_value, 'message' => @message, 'name' => @name, 'status' => @status, 'time' => @time.iso8601(9), } end |
#to_pson(*args) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
62 63 64 |
# File 'lib/puppet/transaction/event.rb', line 62 def to_pson(*args) to_data_hash.to_pson(*args) end |
#to_s ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
86 87 88 |
# File 'lib/puppet/transaction/event.rb', line 86 def to_s end |
#to_yaml_properties ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
90 91 92 |
# File 'lib/puppet/transaction/event.rb', line 90 def to_yaml_properties YAML_ATTRIBUTES & super end |