Sha256: 30f09eeb189eea2926efecf355e3d3622ded8b300acc5abb44f1b5148bc7a554

Contents?: true

Size: 685 Bytes

Versions: 8

Compression:

Stored size: 685 Bytes

Contents

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

  class Configuration

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

    attr_writer *SETTINGS
    attr_accessor :cache

    def initialize
      self.logger = Filum.logger
      self.substitute_values = {}
    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

8 entries across 8 versions & 1 rubygems

Version Path
loquor-1.4.0 lib/loquor/configuration.rb
loquor-1.3.0 lib/loquor/configuration.rb
loquor-1.2.1 lib/loquor/configuration.rb
loquor-1.2.0 lib/loquor/configuration.rb
loquor-1.1.1 lib/loquor/configuration.rb
loquor-1.1.0 lib/loquor/configuration.rb
loquor-1.0.0 lib/loquor/configuration.rb
loquor-0.9.0 lib/loquor/configuration.rb