1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #35226 from olivierlacan/docs/active-job-queue-as-block

Document queue_as block arguments and their use
This commit is contained in:
Rafael França 2019-02-11 18:15:36 -05:00 committed by GitHub
commit 819b06f494
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -18,6 +18,26 @@ module ActiveJob
# post.to_feed!
# end
# end
#
# Can be given a block that will evaluate in the context of the job
# allowing +self.arguments+ to be accessed so that a dynamic queue name
# can be applied:
#
# class PublishToFeedJob < ApplicationJob
# queue_as do
# post = self.arguments.first
#
# if post.paid?
# :paid_feeds
# else
# :feeds
# end
# end
#
# def perform(post)
# post.to_feed!
# end
# end
def queue_as(part_name = nil, &block)
if block_given?
self.queue_name = block