Skip to content

Instantly share code, notes, and snippets.

@benedikt
Created Oct 24, 2011
Embed
What would you like to do?
Pling resque adapter
Pling.configure do |config|
config.gateways.use Pling::Gateway::C2DM, { :email => '', :password => '', :source => '' }
config.adapter = Pling::Adapter::Resque.new
end
Resque.before_first_fork do
Pling.gateways.initialize!
Pling.middlewares.initialize!
end
module Pling
module Adapter
class Resque < Base
@queue = :pling
class << self
def perform(message, device)
message = deserialize(message)
device = deserialize(device)
Pling::Adapter::Base.new.deliver(message, device)
end
def serialize(object)
Marshal.dump(object)
end
def deserialize(object)
Marshal.load(object)
end
end
def deliver(message, device)
message = self.class.serialize(message)
device = self.class.serialize(device)
::Resque.enqueue(self.class, message, device)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment