Class: ExceptionNotifier::SimplepushNotifier

Inherits:
BaseNotifier
  • Object
show all
Defined in:
lib/integrations/simplepush_notifier.rb

Defined Under Namespace

Classes: SimplepushExceptionEvent

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ SimplepushNotifier

Returns a new instance of SimplepushNotifier.



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/integrations/simplepush_notifier.rb', line 10

def initialize(options)
  cred = Rails.application.credentials.simplepush

  if !cred
    Rails.logger.error "Simplepush credentials not found. Please add simplepush credentials to your credentials file."
    @client = nil
    return
  end

  @client = Simplepush.new(cred[:key], cred[:pass], cred[:salt])
  @default_options = options
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



8
9
10
# File 'lib/integrations/simplepush_notifier.rb', line 8

def client
  @client
end

#default_optionsObject (readonly)

Returns the value of attribute default_options.



8
9
10
# File 'lib/integrations/simplepush_notifier.rb', line 8

def default_options
  @default_options
end

Instance Method Details

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



23
24
25
26
27
28
# File 'lib/integrations/simplepush_notifier.rb', line 23

def call(exception, options = {})
  if !@client
    event = SimplepushExceptionEvent.new(exception, options.reverse_merge(default_options))
    @client.send(event.formatted_title, event.formatted_body)
  end
end