diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2019-02-11 18:15:36 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-11 18:15:36 -0500 |
commit | 819b06f494d2b934b3124808526debe0aa81b57a (patch) | |
tree | b33f01fcfa8e02ee123108ee509c896d46f917c8 | |
parent | eb7c71bcd3d0c7e079dffdb11e43fb466eec06aa (diff) | |
parent | e77293786c7f80e4b75f229836a7e8ffbddda30d (diff) | |
download | rails-819b06f494d2b934b3124808526debe0aa81b57a.tar.gz rails-819b06f494d2b934b3124808526debe0aa81b57a.tar.bz2 rails-819b06f494d2b934b3124808526debe0aa81b57a.zip |
Merge pull request #35226 from olivierlacan/docs/active-job-queue-as-block
Document queue_as block arguments and their use
-rw-r--r-- | activejob/lib/active_job/queue_name.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/activejob/lib/active_job/queue_name.rb b/activejob/lib/active_job/queue_name.rb index 7bb1e35181..de259261de 100644 --- a/activejob/lib/active_job/queue_name.rb +++ b/activejob/lib/active_job/queue_name.rb @@ -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 |