class Notifiable::NotifierBase
Attributes
env[R]
notification[R]
Public Class Methods
new(env, notification)
click to toggle source
# File lib/notifiable/notifier_base.rb, line 17 def initialize(env, notification) @env, @notification = env, notification end
notifier_attribute(*vars)
click to toggle source
# File lib/notifiable/notifier_base.rb, line 7 def self.notifier_attribute(*vars) @notifier_attributes ||= [] @notifier_attributes.concat vars attr_writer(*vars) end
notifier_attributes()
click to toggle source
# File lib/notifiable/notifier_base.rb, line 13 def self.notifier_attributes @notifier_attributes end
Public Instance Methods
close()
click to toggle source
# File lib/notifiable/notifier_base.rb, line 25 def close flush save_receipts if Notifiable.save_receipts @notification.save end
send_notification(device_token)
click to toggle source
# File lib/notifiable/notifier_base.rb, line 21 def send_notification(device_token) enqueue(device_token, self.notification) end
Protected Instance Methods
flush()
click to toggle source
# File lib/notifiable/notifier_base.rb, line 32 def flush end
processed(device_token, status, error_message = nil)
click to toggle source
# File lib/notifiable/notifier_base.rb, line 36 def processed(device_token, status, error_message = nil) if @notification.app.save_notification_statuses receipts << {notification_id: self.notification.id, device_token_id: device_token.id, status: status, created_at: DateTime.now, error_message: error_message} 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
test_env?()
click to toggle source
# File lib/notifiable/notifier_base.rb, line 47 def test_env? self.env == "test" end
Private Instance Methods
receipts()
click to toggle source
# File lib/notifiable/notifier_base.rb, line 52 def receipts @receipts ||= [] end
save_receipts()
click to toggle source
# File lib/notifiable/notifier_base.rb, line 56 def save_receipts Notifiable::NotificationStatus.bulk_insert! receipts @receipts = [] end