Module: Namba::Config

Extended by:
Config
Included in:
Namba, Client, Config
Defined in:
lib/namba/config.rb

Constant Summary collapse

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

Instance Method Summary collapse

Instance Method Details

#configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (Namba::Config)

    the object that the method was called on

Raises:



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/namba/config.rb', line 15

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

#optionsObject



28
29
30
31
32
# File 'lib/namba/config.rb', line 28

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