Class: Exceptify::Notification
- Inherits:
-
Object
- Object
- Exceptify::Notification
- Defined in:
- lib/exceptify/notification.rb
Instance Attribute Summary collapse
-
#exception ⇒ Object
readonly
Returns the value of attribute exception.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#request_context ⇒ Object
readonly
Returns the value of attribute request_context.
Instance Method Summary collapse
- #app_name ⇒ Object
- #backtrace ⇒ Object
- #controller ⇒ Object
- #controller_and_action ⇒ Object
- #data ⇒ Object
- #env ⇒ Object
- #env_name ⇒ Object
- #hostname ⇒ Object
-
#initialize(exception, options = {}, clock: Time, hostname: -> { Socket.gethostname }, backtrace_cleaner: nil, **keyword_options) ⇒ Notification
constructor
A new instance of Notification.
- #timestamp ⇒ Object
Constructor Details
#initialize(exception, options = {}, clock: Time, hostname: -> { Socket.gethostname }, backtrace_cleaner: nil, **keyword_options) ⇒ Notification
Returns a new instance of Notification.
11 12 13 14 15 16 17 18 |
# File 'lib/exceptify/notification.rb', line 11 def initialize(exception, = {}, clock: Time, hostname: -> { Socket.gethostname }, backtrace_cleaner: nil, **) @exception = exception @options = .merge() @clock = clock @hostname = hostname @backtrace_cleaner = backtrace_cleaner @request_context = @options[:request_context] || RequestContext.new(@options[:env]) end |
Instance Attribute Details
#exception ⇒ Object (readonly)
Returns the value of attribute exception.
9 10 11 |
# File 'lib/exceptify/notification.rb', line 9 def exception @exception end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
9 10 11 |
# File 'lib/exceptify/notification.rb', line 9 def @options end |
#request_context ⇒ Object (readonly)
Returns the value of attribute request_context.
9 10 11 |
# File 'lib/exceptify/notification.rb', line 9 def request_context @request_context end |
Instance Method Details
#app_name ⇒ Object
43 44 45 |
# File 'lib/exceptify/notification.rb', line 43 def app_name [:app_name] || rails_app_name end |
#backtrace ⇒ Object
28 29 30 31 32 33 |
# File 'lib/exceptify/notification.rb', line 28 def backtrace return [] unless exception.backtrace return @backtrace_cleaner.clean_backtrace(exception) if @backtrace_cleaner exception.backtrace end |
#controller ⇒ Object
51 52 53 |
# File 'lib/exceptify/notification.rb', line 51 def controller request_context.controller end |
#controller_and_action ⇒ Object
55 56 57 |
# File 'lib/exceptify/notification.rb', line 55 def controller_and_action request_context.controller_and_action end |
#data ⇒ Object
24 25 26 |
# File 'lib/exceptify/notification.rb', line 24 def data request_context.exception_data.merge([:data] || {}) end |
#env ⇒ Object
20 21 22 |
# File 'lib/exceptify/notification.rb', line 20 def env request_context.env end |
#env_name ⇒ Object
47 48 49 |
# File 'lib/exceptify/notification.rb', line 47 def env_name Rails.env if defined?(::Rails) && ::Rails.respond_to?(:env) end |
#hostname ⇒ Object
39 40 41 |
# File 'lib/exceptify/notification.rb', line 39 def hostname @hostname.call end |
#timestamp ⇒ Object
35 36 37 |
# File 'lib/exceptify/notification.rb', line 35 def @clock.respond_to?(:current) ? @clock.current : @clock.now end |