Sha256: 3ff03fd784573cdbbde517e81c86545b960b81903c2f921fe131b8964a399f53

Contents?: true

Size: 957 Bytes

Versions: 12

Compression:

Stored size: 957 Bytes

Contents

# frozen_string_literal: true

module SidekiqUniqueJobs
  # Calculates the lock type
  #
  class LockType
    # includes "SidekiqUniqueJobs::SidekiqWorkerMethods"
    # @!parse include SidekiqUniqueJobs::SidekiqWorkerMethods
    include SidekiqUniqueJobs::SidekiqWorkerMethods

    #
    # Computes lock type from job arguments, sidekiq_options.
    #
    # @return [Symbol] the lock type
    # @return [NilClass] if no lock type is found.
    #
    def self.call(item)
      new(item).call
    end

    # @!attribute [r] item
    #   @return [Hash] the Sidekiq job hash
    attr_reader :item

    # @param [Hash] item the Sidekiq job hash
    # @option item [Symbol, nil] :lock the type of lock to use.
    # @option item [String] :class the class of the sidekiq worker
    def initialize(item)
      @item = item
      self.job_class = item[CLASS]
    end

    def call
      item[LOCK] || job_options[LOCK] || default_job_options[LOCK]
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
sidekiq-unique-jobs-8.0.10 lib/sidekiq_unique_jobs/lock_type.rb
sidekiq-unique-jobs-7.1.33 lib/sidekiq_unique_jobs/lock_type.rb
sidekiq-unique-jobs-7.1.32 lib/sidekiq_unique_jobs/lock_type.rb
sidekiq-unique-jobs-8.0.9 lib/sidekiq_unique_jobs/lock_type.rb
sidekiq-unique-jobs-8.0.8 lib/sidekiq_unique_jobs/lock_type.rb
sidekiq-unique-jobs-8.0.7 lib/sidekiq_unique_jobs/lock_type.rb
sidekiq-unique-jobs-8.0.6 lib/sidekiq_unique_jobs/lock_type.rb
sidekiq-unique-jobs-7.1.31 lib/sidekiq_unique_jobs/lock_type.rb
sidekiq-unique-jobs-8.0.5 lib/sidekiq_unique_jobs/lock_type.rb
sidekiq-unique-jobs-8.0.4 lib/sidekiq_unique_jobs/lock_type.rb
sidekiq-unique-jobs-7.1.30 lib/sidekiq_unique_jobs/lock_type.rb
sidekiq-unique-jobs-8.0.3 lib/sidekiq_unique_jobs/lock_type.rb