Sha256: ec9c90d916cb600b3e63f96f0b3f8814b66aa539ff0e78a135ef1f751c8d961a

Contents?: true

Size: 668 Bytes

Versions: 5

Compression:

Stored size: 668 Bytes

Contents

module Propono

  class ProponoConfigurationError < ProponoError
  end

  class Configuration

    SETTINGS = [
      :access_key, :secret_key, :queue_region,
      :application_name,
      :udp_host, :udp_port,
      :tcp_host, :tcp_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

5 entries across 5 versions & 1 rubygems

Version Path
propono-0.9.1 lib/propono/configuration.rb
propono-0.9.0 lib/propono/configuration.rb
propono-0.8.2 lib/propono/configuration.rb
propono-0.8.0 lib/propono/configuration.rb
propono-0.7.0 lib/propono/configuration.rb