mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Extract QueueName into its own module
This commit is contained in:
parent
935f53bd5a
commit
60d76c5651
2 changed files with 14 additions and 13 deletions
|
@ -1,22 +1,13 @@
|
|||
require 'active_job/queue_adapter'
|
||||
require 'active_job/queue_adapters/inline_adapter'
|
||||
require 'active_support/core_ext/string/inflections'
|
||||
require 'active_job/queue_name'
|
||||
|
||||
module ActiveJob
|
||||
class Base
|
||||
extend QueueAdapter
|
||||
extend QueueName
|
||||
|
||||
cattr_accessor(:queue_base_name) { "active_jobs" }
|
||||
cattr_accessor(:queue_name) { queue_base_name }
|
||||
|
||||
class << self
|
||||
def enqueue(*args)
|
||||
queue_adapter.queue self, *args
|
||||
end
|
||||
|
||||
def queue_as(part_name)
|
||||
self.queue_name = "#{queue_base_name}_#{part_name}"
|
||||
end
|
||||
def self.enqueue(*args)
|
||||
queue_adapter.queue self, *args
|
||||
end
|
||||
end
|
||||
end
|
10
lib/active_job/queue_name.rb
Normal file
10
lib/active_job/queue_name.rb
Normal file
|
@ -0,0 +1,10 @@
|
|||
module ActiveJob
|
||||
module QueueName
|
||||
mattr_accessor(:queue_base_name) { "active_jobs" }
|
||||
mattr_accessor(:queue_name) { queue_base_name }
|
||||
|
||||
def queue_as(part_name)
|
||||
self.queue_name = "#{queue_base_name}_#{part_name}"
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue