Sha256: a4caaea6034bc1d2ea7109f5a9f6d4c7e8d77b6aeb5cc297b9a7f5399545a347

Contents?: true

Size: 836 Bytes

Versions: 2

Compression:

Stored size: 836 Bytes

Contents

module VkontakteApi
  # General configuration module.
  # 
  # It extends `VkontakteApi` so it's methods should be called from there.
  module Configuration
    # Available options.
    OPTION_NAMES = [:app_id, :app_secret, :adapter]
    
    attr_accessor *OPTION_NAMES
    
    # Default HTTP adapter.
    DEFAULT_ADAPTER = :net_http
    
    # A global configuration set via the block.
    # @example
    #   VkontakteApi.configure do |config|
    #     config.adapter = :net_http
    #   end
    def configure
      yield self if block_given?
      self
    end
    
    # Reset all configuration options to defaults.
    def reset
      @adapter = DEFAULT_ADAPTER
    end
    
    # When this module is extended, set all configuration options to their default values.
    def self.extended(base)
      base.reset
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vkontakte_api-0.2.1 lib/vkontakte_api/configuration.rb
vkontakte_api-0.2 lib/vkontakte_api/configuration.rb