Sha256: cfd11bfc805073b2ca4d91bf6f72a04fab16e4c6637bf0efcc54130c68f15d19

Contents?: true

Size: 844 Bytes

Versions: 10

Compression:

Stored size: 844 Bytes

Contents

module Inquisitio

  class InquisitioConfigurationError < InquisitioError
  end

  class Configuration

    SETTINGS = [
      :api_version,
      :search_endpoint,
      :document_endpoint,
      :default_search_size,
      :dry_run,
      :logger,
      :max_attempts
    ]

    attr_writer *SETTINGS

    def initialize
      self.logger = Inquisitio::Logger.new
      self.dry_run = false
      self.max_attempts = 3
    end

    SETTINGS.each do |setting|
      define_method setting do
        get_or_raise(setting)
      end
    end

    private

    def get_or_raise(setting)
      val = instance_variable_get("@#{setting.to_s}")
      if setting == :api_version && val.nil?
        val = '2011-02-01'
      end
      val.nil?? raise(InquisitioConfigurationError.new("Configuration for #{setting} is not set")) : val
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
inquisitio-1.5.0 lib/inquisitio/configuration.rb
inquisitio-1.4.1 lib/inquisitio/configuration.rb
inquisitio-1.4.0 lib/inquisitio/configuration.rb
inquisitio-1.3.1 lib/inquisitio/configuration.rb
inquisitio-1.3.0 lib/inquisitio/configuration.rb
inquisitio-1.2.4 lib/inquisitio/configuration.rb
inquisitio-1.2.3 lib/inquisitio/configuration.rb
inquisitio-1.2.2 lib/inquisitio/configuration.rb
inquisitio-1.2.1 lib/inquisitio/configuration.rb
inquisitio-1.2.0 lib/inquisitio/configuration.rb