Sha256: 3809eabceae622172977b4ded40675620761a1c8ecd1afab24e7be889ffc71c1

Contents?: true

Size: 770 Bytes

Versions: 1

Compression:

Stored size: 770 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
      Filum.config do |config|
        config.logfile = "./log/loquor.log"
      end
      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

1 entries across 1 versions & 1 rubygems

Version Path
loquor-0.8.0 lib/loquor/configuration.rb