Sha256: a66c34b289e55d4df112bb1480af3aef41a44f332daf2c51c757716682fad202

Contents?: true

Size: 1.26 KB

Versions: 5

Compression:

Stored size: 1.26 KB

Contents

module RailsBase
  module Configuration
    class ActiveJob < Base
      ACTIVE_JOB_PROC = Proc.new do |val, instance|
        if val.is_a?(Symbol)
          begin
            ::ActiveJob::QueueAdapters.lookup(val)
            RailsBase::ApplicationJob.queue_adapter = val.to_sym
            Rails.configuration.active_job.queue_adapter = val.to_sym
          rescue StandardError => e
            raise ArgumentError, "config.app.active_job_adapter=#{val} is not a defined active job"
          end
        end
      end

      DEFAULT_VALUES = {
        enable_ui: {
          type: :boolean,
          default: true,
          description: 'All ActiveJob UI. To be used downstream'
        },
        view_ui: {
          type: :proc,
          default: ->(user) { user.at_least_owner? },
          dependents: [ -> (i) { i.enable_ui? }],
          description: 'All users to view ActiveJob UI. To be used downstream'
        },
        adapter: {
          type: :symbol_class,
          default: ENV['USE_SIDEKIQ']=='true' ? :sidekiq : :inline,
          on_assignment: ACTIVE_JOB_PROC,
          description: 'Active job adapter. This expects a symbol or a class that inherits from ActiveJob::QueueAdapters'
        },
      }

      attr_accessor *DEFAULT_VALUES.keys
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rails_base-0.72.1 lib/rails_base/configuration/active_job.rb
rails_base-0.72.0 lib/rails_base/configuration/active_job.rb
rails_base-0.71.0 lib/rails_base/configuration/active_job.rb
rails_base-0.70.1.pre lib/rails_base/configuration/active_job.rb
rails_base-0.70.0 lib/rails_base/configuration/active_job.rb