Sha256: 976f1ecbf26f02e34c4a05695f5a74a30cf0204815ca3d1638d7aeb1e811c7e5

Contents?: true

Size: 683 Bytes

Versions: 3

Compression:

Stored size: 683 Bytes

Contents

require 'namba/error'

module Namba
  module Config
    extend self

    VALID_KEYS = [
      :username,
      :password,
      :locale
    ]
	
    attr_accessor *VALID_KEYS

    def configure
      yield self

      # Setting default configuraion options
      # if not provided
      self.tap do |s|
        s.username = "" if s.username.nil? 
        s.password = "" if s.password.nil? 
        s.locale = :kg if s.locale.nil? 
      end
      raise ConfigurationError, "Available locales are only 'kg' and 'net'" unless [:kg, :net].include?(self.locale)
    end

    def options
      options = {}
      VALID_KEYS.each {|k| options[k] = send(k)}
      options
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
namba-1.3.2 lib/namba/config.rb
namba-1.3.1 lib/namba/config.rb
namba-1.3.0 lib/namba/config.rb