Sha256: 17712273eaea50a92aff1e47858b5a99b00c4e53f5f8c9dba0a69a1b3a0918d2

Contents?: true

Size: 1.65 KB

Versions: 5

Compression:

Stored size: 1.65 KB

Contents

# frozen_string_literal: true

module SidekiqUniqueJobs
  module Script
    #
    # Class holding gem configuration
    #
    # @author Mikael Henriksson <mikael@mhenrixon.com>
    class Config
      #
      # @!attribute [r] logger
      #   @return [Logger] a logger to use for debugging
      attr_reader :logger
      #
      # @!attribute [r] scripts_path
      #   @return [Pathname] a directory with lua scripts
      attr_reader :scripts_path

      #
      # Initialize a new instance of {Config}
      #
      #
      def initialize
        @conn         = RedisClient.new
        @logger       = Logger.new($stdout)
        @scripts_path = nil
      end

      #
      # Sets a value for scripts_path
      #
      # @param [String, Pathname] obj <description>
      #
      # @raise [ArgumentError] when directory does not exist
      # @raise [ArgumentError] when argument isn't supported
      #
      # @return [Pathname]
      #
      def scripts_path=(obj)
        raise ArgumentError, "#{obj} should be a Pathname or String" unless obj.is_a?(Pathname) || obj.is_a?(String)
        raise ArgumentError, "#{obj} does not exist" unless Dir.exist?(obj.to_s)

        @scripts_path =
          case obj
          when String
            Pathname.new(obj)
          else
            obj
          end
      end

      #
      # Sets a value for logger
      #
      # @param [Logger] obj a logger to use
      #
      # @raise [ArgumentError] when given argument isn't a Logger
      #
      # @return [Logger]
      #
      def logger=(obj)
        raise ArgumentError, "#{obj} should be a Logger" unless obj.is_a?(Logger)

        @logger = obj
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
sidekiq-unique-jobs-8.0.10 lib/sidekiq_unique_jobs/script/config.rb
sidekiq-unique-jobs-8.0.9 lib/sidekiq_unique_jobs/script/config.rb
sidekiq-unique-jobs-8.0.8 lib/sidekiq_unique_jobs/script/config.rb
sidekiq-unique-jobs-8.0.7 lib/sidekiq_unique_jobs/script/config.rb
sidekiq-unique-jobs-8.0.6 lib/sidekiq_unique_jobs/script/config.rb