Created
October 24, 2011 11:48
-
-
Save benedikt/1308846 to your computer and use it in GitHub Desktop.
Pling resque adapter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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