A simple struct for storing what happens on the system.
# File lib/puppet/transaction/event.rb, line 40 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
# File lib/puppet/transaction/event.rb, line 67 def property=(prop) @property = prop.to_s end
# File lib/puppet/transaction/event.rb, line 71 def resource=(res) if res.respond_to?(:[]) and level = res[:loglevel] @default_log_level = level end @resource = res.to_s end
# File lib/puppet/transaction/event.rb, line 78 def send_log super(log_level, message) end
# File lib/puppet/transaction/event.rb, line 82 def status=(value) raise ArgumentError, "Event status can only be #{EVENT_STATUSES.join(', ')}" unless EVENT_STATUSES.include?(value) @status = value end
# File lib/puppet/transaction/event.rb, line 53 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
# File lib/puppet/transaction/event.rb, line 87 def to_s message end
# File lib/puppet/transaction/event.rb, line 91 def to_yaml_properties YAML_ATTRIBUTES & super end
# File lib/puppet/transaction/event.rb, line 22 def self.from_data_hash(data) obj = self.allocate obj.initialize_from_hash(data) obj end
# File lib/puppet/transaction/event.rb, line 28 def self.from_pson(data) Puppet.deprecation_warning("from_pson is being removed in favour of from_data_hash.") self.from_data_hash(data) end
# File lib/puppet/transaction/event.rb, line 33 def initialize(options = {}) @audited = false set_options(options) @time = Time.now end