Sha256: bceb9c68ca1975622ea1fc725fd20ecb930490b109563aa73891fc9610a3cf80

Contents?: true

Size: 711 Bytes

Versions: 3

Compression:

Stored size: 711 Bytes

Contents

module Loquor
  class LoquorError < StandardError
  end
  class LoquorConfigurationError < LoquorError
  end

  class Configuration

    SETTINGS = [
      :logger, :access_id, :secret_key, :endpoint
    ]

    attr_writer *SETTINGS
    attr_accessor :cache

    def initialize
      Filum.config do |config|
        config.logfile = "./log/loquor.log"
      end
      logger = Filum.logger
    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(LoquorConfigurationError.new("Configuration for #{setting} is not set"))
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
loquor-0.7.0 lib/loquor/configuration.rb
loquor-0.6.0 lib/loquor/configuration.rb
loquor-0.5.4 lib/loquor/configuration.rb