Class: Chronos::Core::Notice

Inherits:
Object
  • Object
show all
Defined in:
lib/chronos/core/notice.rb

Overview

Immutable value object containing a normalized Ruby exception.

Examples:

notice.exception_class #=> "RuntimeError"

Constant Summary collapse

ATTRIBUTES =
[
  :event_id, :exception_class, :message, :backtrace, :causes,
  :severity, :timestamp, :context, :parameters, :session, :user,
  :environment, :runtime, :versions, :host, :process, :thread,
  :tags, :fingerprint
].freeze

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Notice

Returns a new instance of Notice.



24
25
26
27
28
29
# File 'lib/chronos/core/notice.rb', line 24

def initialize(attributes)
  ATTRIBUTES.each do |attribute|
    instance_variable_set("@#{attribute}", deep_freeze(attributes[attribute]))
  end
  freeze
end

Instance Method Details

#to_hObject



31
32
33
34
35
# File 'lib/chronos/core/notice.rb', line 31

def to_h
  ATTRIBUTES.each_with_object({}) do |attribute, result|
    result[attribute] = public_send(attribute)
  end
end