Sha256: 265ea1e68d7fc6bb5db313f79a42edd39117aadf7600744049dc672a3d699dfa

Contents?: true

Size: 806 Bytes

Versions: 4

Compression:

Stored size: 806 Bytes

Contents

require 'active_job/queue_adapters/inline_adapter'
require 'active_support/core_ext/string/inflections'

module ActiveJob
  module QueueAdapter
    extend ActiveSupport::Concern

    included do
      self.queue_adapter = ActiveJob::QueueAdapters::InlineAdapter
    end

    module ClassMethods
      mattr_reader(:queue_adapter)

      def queue_adapter=(name_or_adapter)
        @@queue_adapter = \
          case name_or_adapter
          when :test
            ActiveJob::QueueAdapters::TestAdapter.new
          when Symbol, String
            load_adapter(name_or_adapter)
          when Class
            name_or_adapter
          end
      end

      private
        def load_adapter(name)
          "ActiveJob::QueueAdapters::#{name.to_s.camelize}Adapter".constantize
        end
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
activejob_backport-0.0.3 lib/active_job/queue_adapter.rb
passive_job-0.0.3 lib/active_job/queue_adapter.rb
passive_job-0.0.2 lib/active_job/queue_adapter.rb
activejob_backport-0.0.2 lib/active_job/queue_adapter.rb