class GorgService::Message::ErrorLog
Attributes
debug[RW]
id[RW]
message[RW]
sender[RW]
timestamp[RW]
type[RW]
Public Class Methods
new( type: "info", id: SecureRandom.uuid, sender: GorgService.configuration.application_id, message: "", timestamp: DateTime.now, debug: {})
click to toggle source
# File lib/gorg_service/message/error_log.rb, line 13 def initialize( type: "info", id: SecureRandom.uuid, sender: GorgService.configuration.application_id, message: "", timestamp: DateTime.now, debug: {}) @type=type @id=id @sender=sender @message=message @timestamp=timestamp @debug=debug end
parse(obj)
click to toggle source
# File lib/gorg_service/message/error_log.rb, line 43 def parse(obj) obj=JSON.parse(obj) unless obj.is_a? Hash obj=convert_keys_to_sym(obj) self.new( type: obj[:error_type], id: obj[:error_uuid], sender: obj[:error_sender], message: obj[:error_message], timestamp: DateTime.parse(obj[:timestamp]), debug: obj[:error_debug]) end
Protected Class Methods
convert_keys_to_sym(input_hash)
click to toggle source
# File lib/gorg_service/message/error_log.rb, line 59 def convert_keys_to_sym input_hash s2s = lambda do |h| Hash === h ? Hash[ h.map do |k, v| [k.respond_to?(:to_sym) ? k.to_sym : k, s2s[v]] end ] : h end s2s[input_hash] end
Public Instance Methods
to_h()
click to toggle source
# File lib/gorg_service/message/error_log.rb, line 27 def to_h h={"error_type" => type, "error_uuid" => id, "error_sender" => sender, "error_message" => message, "timestamp" => timestamp.iso8601, } h["error_debug"]= debug if debug h end
to_json()
click to toggle source
# File lib/gorg_service/message/error_log.rb, line 38 def to_json to_h.to_json end