module Knodes::Configuration

Constants

DEFAULT_ADAPTER

The adapter that will be used to connect if none is set The default faraday adapter is Net::HTTP.

DEFAULT_CUSTOMER_ID

By default, don't set a customer ID

DEFAULT_CUSTOMER_SECRET

By default, don't set a customer secret

DEFAULT_ENDPOINT

The endpoint that will be used to connect if none is set

DEFAULT_FORMAT

The response format appended to the path and sent in the 'Accept' header if none is set JSON is the only available format at this time

DEFAULT_PROXY

By default, don't use a proxy server

DEFAULT_USER_AGENT

The user agent that will be sent to the API endpoint if none is set

VALID_OPTIONS_KEYS

Public Class Methods

extended(base) click to toggle source

When this module is extended, set all configuration options to their default values

# File lib/knodes/configuration.rb, line 53
def self.extended(base)
  base.reset
end

Public Instance Methods

configure() { |self| ... } click to toggle source

allow config values to be set in a block

# File lib/knodes/configuration.rb, line 41
def configure
  yield self
end
options() click to toggle source

return hash of options

# File lib/knodes/configuration.rb, line 46
def options
  VALID_OPTIONS_KEYS.inject({}) do |option, key|
    option.merge!(key => send(key))
  end
end
reset() click to toggle source
# File lib/knodes/configuration.rb, line 57
def reset
  self.adapter         = DEFAULT_ADAPTER
  self.customer_id     = DEFAULT_CUSTOMER_ID
  self.customer_secret = DEFAULT_CUSTOMER_SECRET
  self.endpoint        = DEFAULT_ENDPOINT
  self.format          = DEFAULT_FORMAT
  self.proxy           = DEFAULT_PROXY
  self.user_agent      = DEFAULT_USER_AGENT
 end