rails/rails — pull request #12064 by hstove (2013-08-29 02:18:29+00:00)
Title: Implement a queue with namespacing support.

This pull request alters the Rails.queue interface to mimic the previously implemented queue with support for namespacing. This is done using `MultiQueue`, a subclass of `Hash`. `method_missing` is then defined to pass all missing method calls to the default queue. Essentially, you can then call `Rails.queue.push` and other queue-specific methods, which is the same as calling `Rails.queue.default.push`.

If you want to namespace your queues, you can set `Rails.queue[:mailer]=...` and access it through `Rails.queue[:mailer]`.

`Rails.queue=`, `Rails.application.queue=`, and `confiq.queue=` are all aliased to set the method argument as `Rails.queue.default`.

If you *really* want to override the wrapper at `Rails.queue`, you'd have to call `Rails.instance_variable_set(:@queue, arg)`.

Since `MultiQueue` inherits from `Hash`, you can also define [default_proc](http://www.ruby-doc.org/core-2.0/Hash.html#method-i-default_proc-3D) and implement dynamic namespacing.