Module: Chute::Configuration

Included in:
Chute
Defined in:
lib/chute/configuration.rb

Constant Summary collapse

VALID_CONNECTION_KEYS =
[:api_endpoint, :auth_endpoint, :upload_endpoint].freeze
VALID_OPTIONS_KEYS =
[:app_id, :app_secret, :access_token].freeze
VALID_CONFIG_KEYS =
VALID_CONNECTION_KEYS + VALID_OPTIONS_KEYS
DEFAULT_API_ENDPOINT =
'https://api.getchute.com'
DEFAULT_AUTH_ENDPOINT =
'https://getchute.com/auth'
DEFAULT_UPLOAD_ENDPOINT =
'http://upload.getchute.com'
DEFAULT_APP_ID =
'app_id'
DEFAULT_APP_SECRET =
'app_secret'
DEFAULT_ACCESS_TOKEN =
'access_token'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object

[View source]

27
28
29
# File 'lib/chute/configuration.rb', line 27

def self.extended(base)
  base.reset
end

Instance Method Details

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

Yields:

  • (_self)

Yield Parameters:

[View source]

23
24
25
# File 'lib/chute/configuration.rb', line 23

def configure
  yield(self)
end

#optionsObject

[View source]

19
20
21
# File 'lib/chute/configuration.rb', line 19

def options
  Hash[ * VALID_CONFIG_KEYS.map { |key| [key, send(key)] }.flatten ]
end

#resetObject

[View source]

31
32
33
34
35
36
37
38
39
# File 'lib/chute/configuration.rb', line 31

def reset
  self.api_endpoint       = DEFAULT_API_ENDPOINT
  self.auth_endpoint      = DEFAULT_AUTH_ENDPOINT
  self.upload_endpoint    = DEFAULT_UPLOAD_ENDPOINT

  self.app_id             = DEFAULT_APP_ID
  self.app_secret         = DEFAULT_APP_SECRET
  self.access_token       = DEFAULT_ACCESS_TOKEN
end