Sha256: 0e9b6657e3d131d1eee2670a2b7420388338bd2af5719eb522ca8c1ab25b99b6

Contents?: true

Size: 809 Bytes

Versions: 3

Compression:

Stored size: 809 Bytes

Contents

module Propono

  class ProponoConfigurationError < ProponoError
  end

  class Configuration

    SETTINGS = [
      :use_iam_profile, :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 = ""
      self.use_iam_profile = false
    end

    SETTINGS.each do |setting|
      define_method setting do
        get_or_raise(setting)
      end
    end
    
    attr_reader :use_iam_profile
      
    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-1.0.0.rc1 lib/propono/configuration.rb
propono-0.11.1 lib/propono/configuration.rb
propono-0.11.0 lib/propono/configuration.rb