Sha256: 97461fdfd3cd0276003e3baae42e9b4c5be21e0ae652c50934e3cdd17bd1b395

Contents?: true

Size: 894 Bytes

Versions: 4

Compression:

Stored size: 894 Bytes

Contents

module DelayedJobWorkerPool
  class DSL
    SIMPLE_SETTINGS = [:workers, :queues, :min_priority, :max_priority, :sleep_delay, :read_ahead].freeze
    CALLBACK_SETTINGS = [:after_preload_app, :on_worker_boot, :after_worker_boot, :after_worker_shutdown].freeze

    def self.load(path)
      options = {}

      dsl = new(options)
      dsl.instance_eval(File.read(path), path, 1)

      options
    end

    def initialize(options)
      @options = options
    end

    SIMPLE_SETTINGS.each do |option_name|
      define_method(option_name) do |option_value|
        @options[option_name] = option_value unless option_value.nil?
      end
    end

    def preload_app(preload_app = true)
      @options[:preload_app] = preload_app
    end

    CALLBACK_SETTINGS.each do |option_name|
      define_method(option_name) do |&block|
        @options[option_name] = block
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
delayed_job_worker_pool-0.2.3 lib/delayed_job_worker_pool/dsl.rb
delayed_job_worker_pool-0.2.2 lib/delayed_job_worker_pool/dsl.rb
delayed_job_worker_pool-0.2.1 lib/delayed_job_worker_pool/dsl.rb
delayed_job_worker_pool-0.2.0 lib/delayed_job_worker_pool/dsl.rb