Class: RightSupport::Notifier::Notification

Inherits:
Object
  • Object
show all
Defined in:
lib/right_support/notifiers/notification.rb

Overview

definition for a notification to be sent to notifiers.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(error, options = {}) ⇒ Notification

Returns a new instance of Notification.

Parameters:

  • error (Exception)

    leading to notification

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :error_token (String)

    or nil to generate a new token

  • :env (Hash)

    from Rack or nil or empty

  • :global_session (Hash)

    or nil or empty

  • :component (String)

    as optional name of component (the controller name, etc.). default=‘unknown’.

  • :action (String)

    as optional name of action (the controller method invoked by request URI, etc.). default=‘unknown’.



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/right_support/notifiers/notification.rb', line 38

def initialize(error, options = {})
  options = {
    error_token: nil,
    env: nil,
    payload: nil,
    global_session: nil,
    component: 'unknown',
    action: 'unknown',
  }.merge(options)

  @error = error
  @error_token = (options[:error_token] || ::RightSupport::Data::Token.generate).to_s
  @env = (options[:env] || {}).to_hash
  @payload = (options[:payload] || {}).to_hash
  @global_session = (options[:global_session] || {}).to_hash
  @component = options[:component].to_s
  @action = options[:action].to_s
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



27
28
29
# File 'lib/right_support/notifiers/notification.rb', line 27

def action
  @action
end

#componentObject (readonly)

Returns the value of attribute component.



27
28
29
# File 'lib/right_support/notifiers/notification.rb', line 27

def component
  @component
end

#envObject (readonly)

Returns the value of attribute env.



26
27
28
# File 'lib/right_support/notifiers/notification.rb', line 26

def env
  @env
end

#errorObject (readonly)

Returns the value of attribute error.



26
27
28
# File 'lib/right_support/notifiers/notification.rb', line 26

def error
  @error
end

#error_tokenObject (readonly)

Returns the value of attribute error_token.



26
27
28
# File 'lib/right_support/notifiers/notification.rb', line 26

def error_token
  @error_token
end

#global_sessionObject (readonly)

Returns the value of attribute global_session.



26
27
28
# File 'lib/right_support/notifiers/notification.rb', line 26

def global_session
  @global_session
end

#payloadObject (readonly)

Returns the value of attribute payload.



26
27
28
# File 'lib/right_support/notifiers/notification.rb', line 26

def payload
  @payload
end