Module: GooglePlus::Config

Included in:
GooglePlus
Defined in:
lib/google_plus/config.rb

Overview

Defines constants and methods related to configuration

Constant Summary collapse

DEFAULT_ADAPTER =

The HTTP connection adapter that will be used to connect if none is set

:net_http
DEFAULT_CONNECTION_OPTIONS =

The Faraday connection options if none is set

{}
DEFAULT_CONSUMER_KEY =

The consumer key if none is set

nil
DEFAULT_CONSUMER_SECRET =

The consumer secret if none is set

nil
DEFAULT_ENDPOINT =
Note:

This is configurable in case you want to use HTTP instead of HTTPS, specify a different API version, or use a GooglePlus-compatible endpoint.

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

'https://www.googleapis.com/plus/v1'
DEFAULT_GATEWAY =

The gateway server if none is set

nil
DEFAULT_MEDIA_ENDPOINT =

This endpoint will be used by default when updating statuses with media

'https://www.googleapis.com'
DEFAULT_OAUTH_TOKEN =

The oauth token if none is set

nil
DEFAULT_OAUTH_TOKEN_SECRET =

The oauth token secret if none is set

nil
DEFAULT_PROXY =

The proxy server if none is set

nil
DEFAULT_SEARCH_ENDPOINT =
Note:

This is configurable in case you want to use HTTP instead of HTTPS or use a GooglePlus-compatible endpoint.

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

'https://www.googleapis.com'
DEFAULT_USER_AGENT =

The value sent in the ‘User-Agent’ header if none is set

"GooglePlus Ruby Gem #{GooglePlus::Version}"
VALID_OPTIONS_KEYS =

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

[
  :adapter,
  :connection_options,
  :consumer_key,
  :consumer_secret,
  :endpoint,
  :gateway,
  :oauth_token,
  :oauth_token_secret,
  :proxy,
  :search_endpoint,
  :user_agent,
  :media_endpoint
]

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



67
68
69
# File 'lib/google_plus/config.rb', line 67

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:



72
73
74
75
# File 'lib/google_plus/config.rb', line 72

def configure
  yield self
  self
end

#optionsObject

Create a hash of options and their values



78
79
80
81
82
# File 'lib/google_plus/config.rb', line 78

def options
  options = {}
  VALID_OPTIONS_KEYS.each{|k| options[k] = send(k)}
  options
end

#resetObject

Reset all configuration options to defaults



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/google_plus/config.rb', line 85

def reset
  self.adapter            = DEFAULT_ADAPTER
  self.connection_options = DEFAULT_CONNECTION_OPTIONS
  self.consumer_key       = DEFAULT_CONSUMER_KEY
  self.consumer_secret    = DEFAULT_CONSUMER_SECRET
  self.endpoint           = DEFAULT_ENDPOINT
  self.gateway            = DEFAULT_GATEWAY
  self.media_endpoint     = DEFAULT_MEDIA_ENDPOINT
  self.oauth_token        = DEFAULT_OAUTH_TOKEN
  self.oauth_token_secret = DEFAULT_OAUTH_TOKEN_SECRET
  self.proxy              = DEFAULT_PROXY
  self.search_endpoint    = DEFAULT_SEARCH_ENDPOINT
  self.user_agent         = DEFAULT_USER_AGENT
  self
end