Module: Aladtec::Configuration

Included in:
Aladtec
Defined in:
lib/aladtec/configuration.rb

Constant Summary collapse

VALID_CONNECTION_KEYS =
[:endpoint, :method, :user_agent].freeze
VALID_OPTIONS_KEYS =
[:acc_id, :acc_key, :cus_id].freeze
VALID_CONFIG_KEYS =
VALID_CONNECTION_KEYS + VALID_OPTIONS_KEYS
DEFAULT_ENDPOINT =
'https://secure.emsmanager.net/api/index.php'
DEFAULT_METHOD =
:post
DEFAULT_USER_AGENT =
"Aladtec API Ruby Gem #{Aladtec::VERSION}".freeze
DEFAULT_ACC_ID =
nil
DEFAULT_ACC_KEY =
nil
DEFAULT_CUS_ID =
nil

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object


17
18
19
# File 'lib/aladtec/configuration.rb', line 17

def self.extended(base)
  base.reset
end

Instance Method Details

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

Yields:

  • (_self)

Yield Parameters:


31
32
33
# File 'lib/aladtec/configuration.rb', line 31

def configure
  yield self
end

#optionsObject


35
36
37
# File 'lib/aladtec/configuration.rb', line 35

def options
  Hash[ * VALID_CONFIG_KEYS.map { |key| [key, public_send(key)] }.flatten ]
end

#resetObject


21
22
23
24
25
26
27
28
29
# File 'lib/aladtec/configuration.rb', line 21

def reset
  self.endpoint   = DEFAULT_ENDPOINT
  self.method     = DEFAULT_METHOD
  self.user_agent = DEFAULT_USER_AGENT

  self.acc_id     = DEFAULT_ACC_ID
  self.acc_key    = DEFAULT_ACC_KEY
  self.cus_id     = DEFAULT_CUS_ID
end