Sha256: 14f604b5f38bd02954f2e89cb58f16ad93c2da23ecdd3076bd9e65fdfb9d690f

Contents?: true

Size: 1.02 KB

Versions: 146

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true

module ActiveJob
  module QueuePriority
    extend ActiveSupport::Concern

    # Includes the ability to override the default queue priority.
    module ClassMethods
      mattr_accessor :default_priority

      # Specifies the priority of the queue to create the job with.
      #
      #   class PublishToFeedJob < ActiveJob::Base
      #     queue_with_priority 50
      #
      #     def perform(post)
      #       post.to_feed!
      #     end
      #   end
      #
      # Specify either an argument or a block.
      def queue_with_priority(priority = nil, &block)
        if block_given?
          self.priority = block
        else
          self.priority = priority
        end
      end
    end

    included do
      class_attribute :priority, instance_accessor: false, default: default_priority
    end

    # Returns the priority that the job will be created with
    def priority
      if @priority.is_a?(Proc)
        @priority = instance_exec(&@priority)
      end
      @priority
    end
  end
end

Version data entries

146 entries across 142 versions & 11 rubygems

Version Path
activejob-7.0.8.6 lib/active_job/queue_priority.rb
activejob-6.1.7.10 lib/active_job/queue_priority.rb
activejob-6.1.7.9 lib/active_job/queue_priority.rb
activejob-7.0.8.5 lib/active_job/queue_priority.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/activejob-7.0.8.4/lib/active_job/queue_priority.rb
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/activejob-7.0.5.1/lib/active_job/queue_priority.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/activejob-7.0.5.1/lib/active_job/queue_priority.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/activejob-7.0.5.1/lib/active_job/queue_priority.rb
activejob-7.0.8.4 lib/active_job/queue_priority.rb
activejob-6.1.7.8 lib/active_job/queue_priority.rb
activejob-7.0.8.1 lib/active_job/queue_priority.rb
activejob-6.1.7.7 lib/active_job/queue_priority.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/activejob-7.0.3.1/lib/active_job/queue_priority.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/activejob-7.0.2.3/lib/active_job/queue_priority.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/activejob-6.1.6.1/lib/active_job/queue_priority.rb
activejob-7.0.8 lib/active_job/queue_priority.rb
activejob-7.0.7.2 lib/active_job/queue_priority.rb
activejob-6.1.7.6 lib/active_job/queue_priority.rb
activejob-7.0.7.1 lib/active_job/queue_priority.rb
activejob-6.1.7.5 lib/active_job/queue_priority.rb