Sha256: 90e66b8a1bdd5d489ac9e40124907551a6dbf1ae4ad8cc6b344f0b164285bffb
Contents?: true
Size: 1.2 KB
Versions: 1
Compression:
Stored size: 1.2 KB
Contents
module Notifiable class NotifierBase attr_reader :env, :notification def initialize(env, notification) @env, @notification = env, notification end def send_notification(device_token) localized_notification = self.localized_notification(device_token) enqueue(device_token, localized_notification) if localized_notification end def close flush save_receipts end protected def flush end def localized_notification(device_token) self.notification.localized_notification(device_token.locale) end def processed(device_token, status) receipts << {localized_notification_id: self.localized_notification(device_token).id, device_token_id: device_token.id, status: status, created_at: DateTime.now} if receipts.count > Notifiable.notification_status_batch_size save_receipts end end def test_env? self.env == "test" end private def receipts @receipts ||= [] end def save_receipts Notifiable::NotificationStatus.bulk_insert! receipts @receipts = [] end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
notifiable-rails-0.21.1 | lib/notifiable/notifier_base.rb |