module Passworks::Configuration

Constants

DEFAULT_ENDPOINT
DEFAULT_USER_AGENT
VALID_CONFIG_KEYS

@!visibility private

VALID_CONNECTION_KEYS
VALID_OPTION_KEYS

Public Class Methods

default_options() click to toggle source

@!visibility private

# File lib/passworks/configuration.rb, line 37
def self.default_options
  @default_options ||= {
    endpoint:     ENV['PASSWORKS_ENDPOINT']     || DEFAULT_ENDPOINT   ,
    user_agent:   ENV['PASSWORKS_USER_AGENT']   || DEFAULT_USER_AGENT ,
    api_username: ENV['PASSWORKS_API_USERNAME']                       ,
    api_secret:   ENV['PASSWORKS_API_SECRET']                         ,
    debug:        false
  }
end
extended(base) click to toggle source
# File lib/passworks/configuration.rb, line 52
def extended(base)
  base.reset!
end

Public Instance Methods

configure() { |self| ... } click to toggle source
# File lib/passworks/configuration.rb, line 19
def configure
  yield self
end
endpoint() click to toggle source

@return the endpoint address with API version appended

# File lib/passworks/configuration.rb, line 47
def endpoint
  File.join(@endpoint, 'v2').to_s
end
options() click to toggle source
# File lib/passworks/configuration.rb, line 29
def options
  Configuration.default_options.keys.inject({}) do |hash, key|
    hash[key] = self.instance_variable_get(:"@#{key}")
    hash
  end
end
reset!() click to toggle source
# File lib/passworks/configuration.rb, line 23
def reset!
  Configuration.default_options.each do |key, value|
    self.instance_variable_set(:"@#{key}", value)
  end
end