Sha256: a7c6b934741b8d4fbf5cb2c195fe8560fd30789c2ee13c9ccf60d71ad2c6280c

Contents?: true

Size: 595 Bytes

Versions: 2

Compression:

Stored size: 595 Bytes

Contents

require 'singleton'

module Propono

  class ConfigurationError < Exception
  end

  class Configuration
    include Singleton

    SETTINGS = [:access_key, :secret_key, :queue_region, :queue_url]
    attr_writer *SETTINGS

    def initialize
    end

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

    private

    def get_or_raise(setting)
      if val = instance_variable_get("@#{setting.to_s}")
        val
      else
        raise ConfigurationError.new("Configuration for #{setting} is not set")
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
propono-0.1.0 lib/propono/configuration.rb
propono-0.0.1 lib/propono/configuration.rb