Sha256: e677abc69a588fba04dbb977bc2474036cc8dab14b6c0972b9f79e23beb3bf82

Contents?: true

Size: 633 Bytes

Versions: 10

Compression:

Stored size: 633 Bytes

Contents

module Inquisitio

  class InquisitioConfigurationError < InquisitioError
  end

  class Configuration

    SETTINGS = [
      :search_endpoint,
      :document_endpoint,
      :default_search_size,
      :logger
    ]
    attr_writer *SETTINGS

    def initialize
      self.logger = Inquisitio::Logger.new
    end

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

    private

    def get_or_raise(setting)
      instance_variable_get("@#{setting.to_s}") || 
        raise(InquisitioConfigurationError.new("Configuration for #{setting} is not set"))
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
inquisitio-0.1.6 lib/inquisitio/configuration.rb
inquisitio-0.1.5 lib/inquisitio/configuration.rb
inquisitio-0.1.4 lib/inquisitio/configuration.rb
inquisitio-0.1.3 lib/inquisitio/configuration.rb
inquisitio-0.1.2 lib/inquisitio/configuration.rb
inquisitio-0.1.1 lib/inquisitio/configuration.rb
inquisitio-0.1.0 lib/inquisitio/configuration.rb
inquisitio-0.0.13 lib/inquisitio/configuration.rb
inquisitio-0.0.12 lib/inquisitio/configuration.rb
inquisitio-0.0.11 lib/inquisitio/configuration.rb