Module: VkontakteApi::Configuration

Included in:
VkontakteApi
Defined in:
lib/vkontakte_api/configuration.rb

Overview

Note:

VkontakteApi::Configuration extends VkontakteApi so these methods should be called from the latter.

General configuration module.

Constant Summary collapse

OPTION_NAMES =

Available options.

[
  :app_id,
  :app_secret,
  :redirect_uri,
  :adapter,
  :http_verb,
  :faraday_options,
  :max_retries,
  :logger,
  :log_requests,
  :log_errors,
  :log_responses,
  :api_version
]
DEFAULT_ADAPTER =

Default HTTP adapter.

Faraday.default_adapter
DEFAULT_HTTP_VERB =

Default HTTP verb for API methods.

:post
DEFAULT_MAX_RETRIES =

Default max retries count.

2
DEFAULT_LOGGER_OPTIONS =

Logger default options.

{
  requests:  true,
  errors:    true,
  responses: false
}

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object

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



71
72
73
# File 'lib/vkontakte_api/configuration.rb', line 71

def self.extended(base)
  base.reset
end

Instance Method Details

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

A global configuration set via the block.

Examples:

VkontakteApi.configure do |config|
  config.adapter = :net_http
  config.logger  = Rails.logger
end

Yields:

  • (_self)

Yield Parameters:



52
53
54
55
# File 'lib/vkontakte_api/configuration.rb', line 52

def configure
  yield self if block_given?
  self
end

#resetObject

Reset all configuration options to defaults.



58
59
60
61
62
63
64
65
66
67
68
# File 'lib/vkontakte_api/configuration.rb', line 58

def reset
  @adapter         = DEFAULT_ADAPTER
  @http_verb       = DEFAULT_HTTP_VERB
  @faraday_options = {}
  @max_retries     = DEFAULT_MAX_RETRIES
  @logger          = ::Logger.new(STDOUT)
  @log_requests    = DEFAULT_LOGGER_OPTIONS[:requests]
  @log_errors      = DEFAULT_LOGGER_OPTIONS[:errors]
  @log_responses   = DEFAULT_LOGGER_OPTIONS[:responses]
  @api_version     = nil
end