defunkt/resque — pull request #692 by panthomakos (2012-09-25 16:53:19+00:00)
Title: Enable registering of multiple Resque hooks.

Calling `Resque.before_fork {}` would register a hook, but if any other gem, plugin or file also tried to set a before fork hook, the original would be replaced by the new hook. An example of this is the rpm_contrib gem which allows New Relic instrumentation of Resque jobs. The gem defines a `before_first_fork` hook and an `after_fork` hook. This results in conflicts if a user wants to define their own hooks of the same type.

This fix allows multiple hooks to be registered and executes all of them instead of simply executing the last registered hook. I've consolidated the related tests into a single file and added some tests to ensure that the hooks are called, called at the right time, and that multiple hooks can be registered.

This also closes [this pull request](https://github.com/defunkt/resque/pull/680) and [this one](https://github.com/defunkt/resque/pull/537).

The reason the tests were failing in the other pull requests is that the `before_pause` and `after_pause` hooks were being registered using the old hook registration system. I've updated the code for those hooks as well.