Module: RedAlert::Notifier

Included in:
Rack::Notifier, Sidekiq::Notifier
Defined in:
lib/red_alert/notifier.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



5
6
7
# File 'lib/red_alert/notifier.rb', line 5

def self.included(klass)
  klass.extend ClassMethods
end

Instance Method Details

#alert(exception, data = {}) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/red_alert/notifier.rb', line 17

def alert(exception, data = {})
  cleaner = Cleaner.new(filter_keys)
  cleaned_data = cleaner.scrub data
  notification = Notification.build notifier_settings[:subject], template, exception, cleaned_data
  mail = Mail.new(
    to: notifier_settings[:to],
    from: notifier_settings[:from],
    subject: notification.subject,
    body: notification.body
  )
  mail.delivery_method :smtp, notifier_settings[:transport_settings]
  mail.deliver!
end

#filter_keysObject



13
14
15
# File 'lib/red_alert/notifier.rb', line 13

def filter_keys
  PARAMS_DEFAULT_FILTERS
end

#notifier_settingsObject



9
10
11
# File 'lib/red_alert/notifier.rb', line 9

def notifier_settings
  @notifier_settings ||= {}
end