Sha256: 6f01b9bcc98f798a39115afe114210031e22d2b82f0db7e66683bc1f8a7fa95d

Contents?: true

Size: 640 Bytes

Versions: 3

Compression:

Stored size: 640 Bytes

Contents

module Propono

  class ProponoConfigurationError < ProponoError
  end

  class Configuration

    SETTINGS = [
      :access_key, :secret_key, :queue_region,
      :application_name,
      :udp_host, :udp_port,
      :logger
    ]
    attr_writer *SETTINGS

    def initialize
      self.logger = Propono::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(ProponoConfigurationError.new("Configuration for #{setting} is not set"))
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
propono-0.6.3 lib/propono/configuration.rb
propono-0.6.1 lib/propono/configuration.rb
propono-0.6.0 lib/propono/configuration.rb