Sha256: 54dd94fd346368d18175cb7cde264c1e1235de59fad1464d8539a31c8a355b47

Contents?: true

Size: 744 Bytes

Versions: 4

Compression:

Stored size: 744 Bytes

Contents

module Notifiable

	class NotifierBase
    
		def send_notification(notification, device_token)
      # todo - add before hook
      enqueue(notification, device_token)
      # todo - add after hook       				
    end
    
    def close
      flush
      save_receipts
    end
    
    protected
    def flush
      
    end
    
    def processed(notification, device_token)
      receipts << {:notification_id => notification.id, :device_token_id => device_token.id }
      
      if receipts.count > 10000
        save_receipts
      end
    end
    
    private
    def receipts
      @receipts ||= []
    end
    
    def save_receipts
      Notifiable::NotificationDeviceToken.bulk_insert! receipts
      @receipts = []
    end
	end


end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
notifiable-rails-0.3.0 lib/notifiable/notifier_base.rb
notifiable-rails-0.2.0 lib/notifiable/notifier_base.rb
notifiable-rails-0.1.1 lib/notifiable/notifier_base.rb
notifiable-rails-0.1.0 lib/notifiable/notifier_base.rb