Sha256: 9081b8b59cdcc654b5f4f186d4d7547897b0a83dbab237ec0721e4f624d54dc4
Contents?: true
Size: 1.46 KB
Versions: 10
Compression:
Stored size: 1.46 KB
Contents
module Notifiable class NotifierBase attr_reader :env, :notification def self.notifier_attribute(*vars) @notifier_attributes ||= [] @notifier_attributes.concat vars attr_writer(*vars) end def self.notifier_attributes @notifier_attributes end def initialize(env, notification) @env, @notification = env, notification end def send_notification(device_token) enqueue(device_token, self.notification) end def close flush save_receipts if Notifiable.save_receipts @notification.save end protected def flush end def processed(device_token, status) if @notification.app.save_notification_statuses receipts << {notification_id: self.notification.id, device_token_id: device_token.id, status: status, created_at: DateTime.now} save_receipts if receipts.count >= Notifiable.notification_status_batch_size end @notification.sent_count += 1 @notification.gateway_accepted_count += 1 if status == 0 @notification.save if (@notification.sent_count % Notifiable.notification_status_batch_size == 0) 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
10 entries across 10 versions & 1 rubygems