Sha256: 7c5c4122969f0a3d4f2738a48fba6e2d3f912efd685f628e5bf276ae0966efd4

Contents?: true

Size: 675 Bytes

Versions: 7

Compression:

Stored size: 675 Bytes

Contents

require 'singleton'

module Propono

  class ConfigurationError < Exception
  end

  class Configuration
    include Singleton

    SETTINGS = [
      :access_key,
      :secret_key,
      :queue_region,
      :application_name,
      :logger
    ]
    attr_writer *SETTINGS

    def initialize
      self.logger = $stderr
    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

7 entries across 7 versions & 1 rubygems

Version Path
propono-0.5.4 lib/propono/configuration.rb
propono-0.5.3 lib/propono/configuration.rb
propono-0.5.2 lib/propono/configuration.rb
propono-0.5.1 lib/propono/configuration.rb
propono-0.5.0 lib/propono/configuration.rb
propono-0.4.0 lib/propono/configuration.rb
propono-0.3.0 lib/propono/configuration.rb