Sha256: 37ebd8b61d72e6abc98e8021ec7efe4a7778f6300a06da39e0639c2250174b91

Contents?: true

Size: 681 Bytes

Versions: 6

Compression:

Stored size: 681 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 'kz'" unless [:kg, :kz].include?(self.locale)
    end

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
namba-1.2.0 lib/namba/config.rb
namba-1.1.0 lib/namba/config.rb
namba-1.0.1 lib/namba/config.rb
namba-1.0.0.1 lib/namba/config.rb
namba-1.0.0 lib/namba/config.rb
namba-0.0.1 lib/namba/config.rb