Module: Smspilot::Configuration

Included in:
Smspilot
Defined in:
lib/smspilot/configuration.rb

Constant Summary collapse

VALID_OPTIONS_KEYS =
[:endpoint, :user_agent, :adapter, :timeout, :api_key, :logger, :login, :password]
DEFAULT_ADAPTER =
:net_http
DEFAULT_ENDPOINT =
'http://smspilot.ru/api2.php'
DEFAULT_USER_AGENT =
"smspilot gem #{Smspilot::VERSION}".freeze
DEFAULT_TIMEOUT =
5
DEFAILT_API_KEY =
nil
DEFAILT_LOGIN =
nil
DEFAILT_PASSWORD =
nil
DEFAILT_LOGGER =
Logger.new("log/smspilot.log")

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



23
24
25
# File 'lib/smspilot/configuration.rb', line 23

def self.extended(base)
  base.reset
end

Instance Method Details

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

Yields:

  • (_self)

Yield Parameters:



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

def configure
  yield self
end

#optionsObject



27
28
29
30
31
# File 'lib/smspilot/configuration.rb', line 27

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

#resetObject



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/smspilot/configuration.rb', line 33

def reset
  self.adapter    = DEFAULT_ADAPTER
  self.endpoint   = DEFAULT_ENDPOINT
  self.user_agent = DEFAULT_USER_AGENT
  self.timeout    = DEFAULT_TIMEOUT
  self.api_key    = DEFAILT_API_KEY
  self.      = DEFAILT_LOGIN
  self.password   = DEFAILT_PASSWORD
  self.logger     = DEFAILT_LOGGER
  self
end