diff options
Diffstat (limited to 'activejob/lib/active_job/queue_name.rb')
-rw-r--r-- | activejob/lib/active_job/queue_name.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/activejob/lib/active_job/queue_name.rb b/activejob/lib/active_job/queue_name.rb new file mode 100644 index 0000000000..9698835b6e --- /dev/null +++ b/activejob/lib/active_job/queue_name.rb @@ -0,0 +1,21 @@ +module ActiveJob + module QueueName + extend ActiveSupport::Concern + + module ClassMethods + mattr_accessor(:queue_name_prefix) + mattr_accessor(:default_queue_name) { "default" } + + def queue_as(part_name) + queue_name = part_name.to_s.presence || default_queue_name + name_parts = [queue_name_prefix.presence, queue_name] + self.queue_name = name_parts.compact.join('_') + end + end + + included do + class_attribute :queue_name + self.queue_name = default_queue_name + end + end +end |