Sha256: 280ad877908dcadc13da10a9f46590d35ee7cb18c0d2eba068b082cb64a5f6b4

Contents?: true

Size: 877 Bytes

Versions: 11

Compression:

Stored size: 877 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,
      :max_retries
    ]
    attr_writer *SETTINGS

    def initialize
      self.logger = Propono::Logger.new
      self.queue_suffix = ""
      self.use_iam_profile = false
      self.max_retries = 0
    end

    SETTINGS.each do |setting|
      define_method setting do
        get_or_raise(setting)
      end
    end

    attr_reader :use_iam_profile, :queue_suffix

    private

    def get_or_raise(setting)
      val = instance_variable_get("@#{setting.to_s}")
      val.nil?? raise(ProponoConfigurationError.new("Configuration for #{setting} is not set")) : val
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
propono-1.6.0 lib/propono/configuration.rb
propono-1.5.0 lib/propono/configuration.rb
propono-1.4.0 lib/propono/configuration.rb
propono-1.3.0 lib/propono/configuration.rb
propono-1.2.0 lib/propono/configuration.rb
propono-1.1.3 lib/propono/configuration.rb
propono-1.1.2 lib/propono/configuration.rb
propono-1.1.1 lib/propono/configuration.rb
propono-1.1.0 lib/propono/configuration.rb
propono-1.0.0 lib/propono/configuration.rb
propono-1.0.0.rc3 lib/propono/configuration.rb