Module: Skittles::Configuration

Included in:
Skittles
Defined in:
lib/skittles/configuration.rb

Overview

Defines constants and methods related to configuration.

Constant Summary

VALID_OPTIONS_KEYS =

An array of valid keys in the options hash when configuring a Flixated::API.

[
	:access_token,
	:authorization_endpoint,
	:client_id,
	:client_secret,
	:endpoint,
	:proxy,
	:user_agent
].freeze
DEFAULT_ACCESS_TOKEN =

By default, don't set a user access token.

nil.freeze
DEFAULT_AUTHORIZATION_ENDPOINT =

The endpoint that will be used to authorize a user if none is set.

'https://foursquare.com/oauth2/authenticate'.freeze
DEFAULT_CLIENT_ID =

By default, don't set a client id.

nil.freeze
DEFAULT_CLIENT_SECRET =

By default, don't set a cliet secret.

nil.freeze
DEFAULT_ENDPOINT =

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

'https://api.foursquare.com/v2'.freeze
DEFAULT_PROXY =

By default, don't set a proxy server.

nil.freeze
DEFAULT_USER_AGENT =

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

"skittles gem v#{Skittles::VERSION}".freeze

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.



42
43
44
# File 'lib/skittles/configuration.rb', line 42

def self.extended(base)
	base.reset
end

Instance Method Details

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

Convenience method to allow configuration options to be set in a block.

Yields:

  • (_self)

Yield Parameters:



47
48
49
# File 'lib/skittles/configuration.rb', line 47

def configure
	yield self
end

#optionsObject

Create a hash of options and their values.



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

def options
	VALID_OPTIONS_KEYS.inject({}) do |option,key|
		option.merge!(key => send(key))
	end
end

#resetObject

Reset all configuration options to default.



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

def reset
	self.access_token           = DEFAULT_ACCESS_TOKEN
	self.authorization_endpoint = DEFAULT_AUTHORIZATION_ENDPOINT
	self.client_id              = DEFAULT_CLIENT_ID
	self.client_secret          = DEFAULT_CLIENT_SECRET
	self.endpoint               = DEFAULT_ENDPOINT
	self.proxy                  = DEFAULT_PROXY
	self.user_agent             = DEFAULT_USER_AGENT
end