Class: ThecoreBackendCommons::PushNotificationService

Inherits:
Object
  • Object
show all
Defined in:
lib/thecore_backend_commons/push_notification_service.rb

Constant Summary collapse

MAX_MESSAGES_DEFAULT =
500

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(subscriber, message) ⇒ PushNotificationService

Returns a new instance of PushNotificationService.



9
10
11
12
# File 'lib/thecore_backend_commons/push_notification_service.rb', line 9

def initialize(subscriber, message)
  @subscriber = subscriber
  @message = message
end

Class Method Details

.dispatch(subscriber, message) ⇒ Object



5
6
7
# File 'lib/thecore_backend_commons/push_notification_service.rb', line 5

def self.dispatch(subscriber, message)
  new(subscriber, message).dispatch
end

Instance Method Details

#dispatchObject



14
15
16
17
18
19
20
21
# File 'lib/thecore_backend_commons/push_notification_service.rb', line 14

def dispatch
  send_push
  prune_old_messages
  @message
rescue => e
  Rails.logger.error("[PushNotificationService] dispatch failed: #{e.message}")
  @message
end