Module: Simplesol::Configuration

Included in:
Client
Defined in:
lib/simplesol/configuration.rb

Constant Summary collapse

VALID_OPTIONS_KEYS =
[:login, :api_key, :debug, :api_server]
DEFAULT_LOGIN =
nil
DEFAULT_API_KEY =
nil
DEFAULT_DEBUG =
true
DEFAULT_API_SERVER =
'http://api.gosmsinfo.ru/api'

Instance Method Summary collapse

Instance Method Details

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

Yields:

  • (_self)

Yield Parameters:



19
20
21
# File 'lib/simplesol/configuration.rb', line 19

def configure
  yield self
end

#configured?Boolean

Returns:

  • (Boolean)


14
15
16
17
# File 'lib/simplesol/configuration.rb', line 14

def configured?
  status =  && api_key && api_server
  !(status.nil? || status.empty?)
end

#optionsObject



23
24
25
26
27
# File 'lib/simplesol/configuration.rb', line 23

def options
  VALID_OPTIONS_KEYS.inject({}) do |option, key|
    option.merge!(key => send(key))
  end
end

#resetObject



29
30
31
32
33
# File 'lib/simplesol/configuration.rb', line 29

def reset
  VALID_OPTIONS_KEYS.each do |key|
    send("#{key}=", Simplesol::Configuration.const_get("default_#{key}".upcase))
  end
end