Sha256: b14c24b4959c91d634bcab6caf582776e883f6f5d922bee89a976f5e52ae3b5e

Contents?: true

Size: 712 Bytes

Versions: 1

Compression:

Stored size: 712 Bytes

Contents

module Propono

  class ProponoConfigurationError < ProponoError
  end

  class Configuration

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

    def initialize
      self.logger = Propono::Logger.new
      self.queue_suffix = ""
    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

1 entries across 1 versions & 1 rubygems

Version Path
propono-0.10.0 lib/propono/configuration.rb