mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Dont need the explicit error handling -- if the require fails, it will raise exactly the error we want to communicate anyway. Also use the load path, so we can allow plugins, rather than requre_relative
This commit is contained in:
parent
d7c30987ff
commit
fd1e61adfc
2 changed files with 2 additions and 26 deletions
|
@ -1,9 +1,7 @@
|
||||||
require 'active_job/errors'
|
|
||||||
require 'active_job/queue_adapters/inline_adapter'
|
require 'active_job/queue_adapters/inline_adapter'
|
||||||
require 'active_support/core_ext/string/inflections'
|
require 'active_support/core_ext/string/inflections'
|
||||||
|
|
||||||
module ActiveJob
|
module ActiveJob
|
||||||
|
|
||||||
class Base
|
class Base
|
||||||
cattr_accessor(:queue_adapter) { ActiveJob::QueueAdapters::InlineAdapter }
|
cattr_accessor(:queue_adapter) { ActiveJob::QueueAdapters::InlineAdapter }
|
||||||
cattr_accessor(:queue_base_name) { "active_jobs" }
|
cattr_accessor(:queue_base_name) { "active_jobs" }
|
||||||
|
@ -19,19 +17,9 @@ module ActiveJob
|
||||||
end
|
end
|
||||||
|
|
||||||
def adapter=(adapter_name)
|
def adapter=(adapter_name)
|
||||||
adapter_name = adapter_name.to_s
|
require "active_job/queue_adapters/#{adapter_name}_adapter"
|
||||||
unless %w(inline resque sidekiq sucker_punch).include?(adapter_name)
|
ActiveJob::Base.queue_adapter = "ActiveJob::QueueAdapters::#{adapter_name.to_s.camelize}Adapter".constantize
|
||||||
fail ActiveJob::NotImplementedError
|
|
||||||
end
|
|
||||||
|
|
||||||
begin
|
|
||||||
require_relative "queue_adapters/#{adapter_name}_adapter"
|
|
||||||
ActiveJob::Base.queue_adapter = "ActiveJob::QueueAdapters::#{adapter_name.camelize}Adapter".constantize
|
|
||||||
rescue
|
|
||||||
fail ActiveJob::Error.new("#{adapter_name} is missing")
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
|
||||||
end
|
end
|
|
@ -1,12 +0,0 @@
|
||||||
module ActiveJob
|
|
||||||
|
|
||||||
class NotImplementedError < ::NotImplementedError #:nodoc:
|
|
||||||
end
|
|
||||||
|
|
||||||
class Error < ::StandardError #:nodoc:
|
|
||||||
def initialize(message = nil)
|
|
||||||
super(message)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
Loading…
Reference in a new issue