Sha256: 7aecde014327d0574d547b270a3e4988a0cf4035896746287f4d2697eafcf3df

Contents?: true

Size: 874 Bytes

Versions: 4

Compression:

Stored size: 874 Bytes

Contents

module APN
  # This is the class that's actually enqueued via Resque when user calls +APN.notify+.
  # It gets added to the +apple_server_notifications+ Resque queue, which should only be operated on by
  # workers of the +APN::Sender+ class.
  class NotificationJob
    # Behind the scenes, this is the name of our Resque queue
    @queue = APN::QUEUE_NAME

    # Build a notification from arguments and send to Apple
    def self.perform(token, opts)
      msg = APN::Notification.new(token, opts)
      raise "Invalid notification options: #{opts.inspect}" unless msg.valid?

      worker.send_to_apple( msg )
    end


    # Only execute this job in specialized APN::Sender workers, since
    # standard Resque workers don't maintain the persistent TCP connection.
    extend Resque::Plugins::AccessWorkerFromJob
    self.required_worker_class = 'APN::Sender'
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
apn_sender-0.0.7 lib/apn/notification_job.rb
apn_sender-0.0.6 lib/apn/notification_job.rb
apn_sender-0.0.5 lib/apn/notification_job.rb
apn_sender-0.0.4 lib/apn/notification_job.rb