Module: Flowthings::Configuration

Included in:
Flowthings
Defined in:
lib/flowthings/configuration.rb

Constant Summary collapse

VALID_OPTIONS_KEYS =
[:account_name, :account_token].freeze
VALID_CONNECTION_KEYS =
[:endpoint, :user_agent, :secure, :platform_version]
VALID_CONFIG_KEYS =
VALID_CONNECTION_KEYS + VALID_OPTIONS_KEYS
DEFAULT_ENDPOINT =
"api.flowthings.io"
DEFAULT_USER_AGENT =
"Flowthings API Ruby Gem #{Flowthings::VERSION}".freeze
DEFAULT_ACCOUNT_TOKEN =
nil
DEFAULT_ACCOUNT_NAME =
nil
DEFAULT_SECURE =
true
DEFAULT_PLATFORM_VERSION =
'v0.1'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



17
18
19
# File 'lib/flowthings/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/flowthings/configuration.rb', line 31

def configure
  yield self
end

#optionsObject



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

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

#resetObject



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

def reset
  self.endpoint = DEFAULT_ENDPOINT
  self.user_agent = DEFAULT_USER_AGENT
  self.secure = DEFAULT_SECURE
  self.platform_version = DEFAULT_PLATFORM_VERSION

  self. = DEFAULT_ACCOUNT_TOKEN
  self. = DEFAULT_ACCOUNT_NAME
end