Class: Exceptify::SnsNotifier

Inherits:
BaseNotifier show all
Defined in:
lib/exceptify/sns_notifier.rb

Instance Attribute Summary

Attributes inherited from BaseNotifier

#base_options

Instance Method Summary collapse

Methods inherited from BaseNotifier

#_post_callback, #_pre_callback, #send_notice

Constructor Details

#initialize(options) ⇒ SnsNotifier

Returns a new instance of SnsNotifier.



5
6
7
8
9
10
11
# File 'lib/exceptify/sns_notifier.rb', line 5

def initialize(options)
  options = options.dup
  super

  @notifier = options.delete(:client) || build_client(options)
  @options = default_options.merge(options)
end

Instance Method Details

#call(exception, custom_opts = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/exceptify/sns_notifier.rb', line 13

def call(exception, custom_opts = {})
  custom_options = options.merge(custom_opts)
  notification = Notification.new(exception, custom_options)

  subject = build_subject(notification, custom_options)
  message = build_message(notification, custom_options)

  notifier.publish(
    topic_arn: custom_options[:topic_arn],
    message: message,
    subject: subject
  )
end