Class: Babysitter::ExceptionNotifiers::SimpleNotificationService

Inherits:
Object
  • Object
show all
Defined in:
lib/babysitter/exception_notifiers/simple_notification_service.rb

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ SimpleNotificationService

Returns a new instance of SimpleNotificationService.

Raises:

  • (ArgumentError)


6
7
8
9
10
11
12
13
# File 'lib/babysitter/exception_notifiers/simple_notification_service.rb', line 6

def initialize(opts = {})
  @topic_arn = opts.delete(:topic_arn)
  @get_credentials = opts.delete(:credentials)
  raise ArgumentError, "topic_arn is required." if @topic_arn.nil?
  raise ArgumentError, "credentials is required and must be a Proc." if @get_credentials.nil? || !@get_credentials.is_a?(Proc)

  validate_topic
end

Instance Method Details

#notify(subject, msg) ⇒ Object



15
16
17
# File 'lib/babysitter/exception_notifiers/simple_notification_service.rb', line 15

def notify(subject, msg)
  topic.publish(msg, subject: sanitise_subject(subject))
end