mperham/sidekiq — pull request #357 by elado (2012-08-18 12:31:29+00:00)
Title: Argument serialization into redis

ActiveRecord, classes, modules and other parameters are serialized into custom strings such as "SIDEKIQ@User@2" and "SIDEKIQ@SomeClass" (similar to DelayedJob) in order to have minimum concern about deserialization on the worker methods (used w/ #delay)/worker classes and minimum storage (not storing full serialized AR object but only its ID).

Every class can implement serialization by an instance method `sidekiq_serialize` that returns a string prefixed with `SIDEKIQ` followed by `@` and the class name, followed by an optional `@` with arguments for the deserialization.
Deserialization is implement by by a class method `sidekiq_deserialize(string)` which gets the argument after the second @ and should return the instance.

ActiveRecord instances will serialize to `SIDEKIQ@User@2`, and when deserialized, the `User` will be extracted and constantized, then `2` will be passed to `User.sidekiq_deserialize(2)` which will return `User.where(id: 2)`