1
0
Fork 0
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:
David Heinemeier Hansson 2014-05-19 11:04:23 +02:00
parent 935f53bd5a
commit 60d76c5651
2 changed files with 14 additions and 13 deletions

View file

@ -1,22 +1,13 @@
require 'active_job/queue_adapter' require 'active_job/queue_adapter'
require 'active_job/queue_adapters/inline_adapter' require 'active_job/queue_name'
require 'active_support/core_ext/string/inflections'
module ActiveJob module ActiveJob
class Base class Base
extend QueueAdapter extend QueueAdapter
extend QueueName
cattr_accessor(:queue_base_name) { "active_jobs" } def self.enqueue(*args)
cattr_accessor(:queue_name) { queue_base_name } queue_adapter.queue self, *args
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
end end
end end
end end

View 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