Sha256: 093d64b283a28af479636e6b18494f7e4f99d76828ed1cc303a2b469e6928d99

Contents?: true

Size: 1.01 KB

Versions: 35

Compression:

Stored size: 1.01 KB

Contents

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

      self.priority = 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

35 entries across 35 versions & 4 rubygems

Version Path
activejob-5.0.7.2 lib/active_job/queue_priority.rb
activejob-5.0.7.1 lib/active_job/queue_priority.rb
activejob-5.0.7 lib/active_job/queue_priority.rb
activejob-5.0.6 lib/active_job/queue_priority.rb
activejob-5.0.6.rc1 lib/active_job/queue_priority.rb
activejob-5.0.5 lib/active_job/queue_priority.rb
activejob-5.0.5.rc2 lib/active_job/queue_priority.rb
activejob-5.0.5.rc1 lib/active_job/queue_priority.rb
activejob-5.0.4 lib/active_job/queue_priority.rb
activejob-5.0.4.rc1 lib/active_job/queue_priority.rb
activejob-5.0.3 lib/active_job/queue_priority.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/activejob-5.0.2/lib/active_job/queue_priority.rb
activejob-5.0.2 lib/active_job/queue_priority.rb
activejob-5.0.2.rc1 lib/active_job/queue_priority.rb
autocompl-0.2.2 test/dummy/vendor/bundle/ruby/2.3.0/gems/activejob-5.0.1/lib/active_job/queue_priority.rb
autocompl-0.2.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/activejob-5.0.1/lib/active_job/queue_priority.rb
autocompl-0.2.0 test/dummy/vendor/bundle/ruby/2.3.0/gems/activejob-5.0.1/lib/active_job/queue_priority.rb
autocompl-0.1.2 test/dummy/vendor/bundle/ruby/2.3.0/gems/activejob-5.0.1/lib/active_job/queue_priority.rb
autocompl-0.1.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/activejob-5.0.1/lib/active_job/queue_priority.rb
autocompl-0.1.0 test/dummy/vendor/bundle/ruby/2.3.0/gems/activejob-5.0.1/lib/active_job/queue_priority.rb