Module: GoogleAPI
- Defined in:
- lib/google-api/active_record_inclusions.rb,
lib/google-api.rb,
lib/google-api/api.rb,
lib/google-api/client.rb,
lib/google-api/railtie.rb,
lib/google-api/encrypter.rb
Overview
Adapted from Paperclip’s implementation of available migration methods github.com/thoughtbot/paperclip/blob/v3.1.4/lib/paperclip/schema.rb
Defined Under Namespace
Modules: ActiveRecordInclusions Classes: API, Client, Encrypter, Railtie
Class Attribute Summary collapse
-
.client_id ⇒ Object
Returns the value of attribute client_id.
-
.client_secret ⇒ Object
Returns the value of attribute client_secret.
-
.development_mode ⇒ Object
Returns the value of attribute development_mode.
-
.encryption_key ⇒ Object
Returns the value of attribute encryption_key.
-
.logger ⇒ Object
Returns the value of attribute logger.
Class Method Summary collapse
-
.configure {|_self| ... } ⇒ Object
Configuration options:.
-
.discovered_apis ⇒ Object
An internally used hash to cache the discovered API responses.
-
.reset_environment! ⇒ Object
Used primarily within the test suite to reset our GoogleAPI environment for each test.
-
.stdout_logger ⇒ Object
The default logger for this API.
Class Attribute Details
.client_id ⇒ Object
Returns the value of attribute client_id.
20 21 22 |
# File 'lib/google-api.rb', line 20 def client_id @client_id end |
.client_secret ⇒ Object
Returns the value of attribute client_secret.
20 21 22 |
# File 'lib/google-api.rb', line 20 def client_secret @client_secret end |
.development_mode ⇒ Object
Returns the value of attribute development_mode.
20 21 22 |
# File 'lib/google-api.rb', line 20 def development_mode @development_mode end |
.encryption_key ⇒ Object
Returns the value of attribute encryption_key.
20 21 22 |
# File 'lib/google-api.rb', line 20 def encryption_key @encryption_key end |
.logger ⇒ Object
Returns the value of attribute logger.
20 21 22 |
# File 'lib/google-api.rb', line 20 def logger @logger end |
Class Method Details
.configure {|_self| ... } ⇒ Object
Configuration options:
development_mode: make it easier to build your application with this API. Default is false
logger: if this gem is included in a Rails app, we will use the Rails.logger, otherwise, we log to STDOUT
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/google-api.rb', line 26 def configure yield self raise ArgumentError, "GoogleAPI requires both a :client_id and :client_secret configuration option to be set." unless [client_id, client_secret, encryption_key].all? @development_mode ||= false @logger ||= defined?(::Rails) ? Rails.logger : stdout_logger self end |
.discovered_apis ⇒ Object
An internally used hash to cache the discovered API responses. Keys could be ‘drive’, ‘calendar’, ‘contacts’, etc. Values will be a parsed JSON hash.
40 41 42 |
# File 'lib/google-api.rb', line 40 def discovered_apis @discovered_apis ||= {} end |
.reset_environment! ⇒ Object
Used primarily within the test suite to reset our GoogleAPI environment for each test.
53 54 55 56 57 |
# File 'lib/google-api.rb', line 53 def reset_environment! @development_mode = false @logger = nil @discovered_apis = {} end |
.stdout_logger ⇒ Object
The default logger for this API. When we aren’t within a Rails app, we will output log messages to STDOUT.
46 47 48 49 50 |
# File 'lib/google-api.rb', line 46 def stdout_logger logger = Logger.new(STDOUT) logger.progname = "google-api" logger end |