Sha256: 5efef4b84080cabb84fe985f621a984b5b1e0da5759b513b1701629b7b1c920b

Contents?: true

Size: 883 Bytes

Versions: 2

Compression:

Stored size: 883 Bytes

Contents

module Propono

  class ProponoConfigurationError < ProponoError
  end

  class Configuration

    SETTINGS = [
      :use_iam_profile, :access_key, :secret_key, :queue_region, :queue_suffix,
      :application_name,
      :logger,
      :max_retries, :num_messages_per_poll
    ]
    attr_writer *SETTINGS

    def initialize
      self.logger = Propono::Logger.new
      self.queue_suffix = ""
      self.use_iam_profile = false
      self.max_retries = 0
      self.num_messages_per_poll = 10
    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

2 entries across 2 versions & 1 rubygems

Version Path
propono-2.0.0.rc2 lib/propono/configuration.rb
propono-2.0.0.rc1 lib/propono/configuration.rb