collectiveidea/delayed_job — pull request #324 by rchekaluk (2011-12-24 23:02:41+00:00)
Title: Allow application to access yaml being deserialized

This is the 1st of two companion pull requests (the other in delayed_job_active_record), though this modification can stand alone. When delayed_job changed its deserialization approach to deserialize by populating objects from the database, it lost the ability to deserialize yaml containing extra values beyond database attributes (such as transient attributes). This ability had been available in earlier versions of delayed_job, whether intentionally or not.

This pull request implements a modification that respects the yaml being deserialized by passing it to init_with a second time after populating the deserialized object. This second call to init_with permits application code to intercept the raw yaml being deserialized and act on it.

This modification has been tested in this environment:
- Ruby 1.9.2
- Rubygems 1.8.12
- Gem psych 1.2.2 (the modification doesnt work using native Ruby psych 1.0.0)
- Bundler 1.1.rc.3
- Rails 3.0.10 and 3.1.3

This modification was also tested embedded into an app on Heroku:
- Stack cedar
- Ruby 1.9.2
- Gem psych 1.2.2 (native Ruby psych 1.0.0 not available on Heroku)
- Bundler 1.1.rc.5
- Rails 3.0.10