Class: Notification

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/notification.rb

Overview

Represents an in-app notification message.

Constant Summary collapse

LEVELS_RFC_5424 =

8 log levels according to RFC 5424 (http://tools.ietf.org/html/rfc5424)

{
    debug:  100 ,    # Detailed debug information.
    info:   200,     # Interesting events. Examples: User logs in, SQL logs.
    notice: 250,   # Normal but significant events.
    warning: 300,  # Exceptional occurrences that are not errors. Undesirable things that are not necessarily wrong.
    error:  400,    # Runtime errors that do not require immediate action but should typically be logged and monitored.
    critical: 500, # Critical conditions. Example: Application component unavailable, unexpected exception.
    alert: 550,    # Action must be taken immediately. Example: Entire website down, database unavailable, etc.
    emergency: 600 # Emergency: system is unusable.
}

Instance Method Summary collapse

Instance Method Details

#level=(value) ⇒ Object

Parameters:

  • value

    integer or symbol - valid symbols are listed in LEVELS_RFC_5424


22
23
24
25
26
27
# File 'app/models/notification.rb', line 22

def level= value
  if LEVELS_RFC_5424.include?(value)
    value = LEVELS_RFC_5424[value]
  end
  super(value)
end

#level_to_sObject

Returns String

Returns:

  • String


35
36
37
# File 'app/models/notification.rb', line 35

def level_to_s
  LEVELS_RFC_5424.key(level).to_s
end

#level_to_symObject

Returns Symbol

Returns:

  • Symbol


30
31
32
# File 'app/models/notification.rb', line 30

def level_to_sym
  LEVELS_RFC_5424.key(level)
end