Module: Yt::Config

Included in:
Yt
Defined in:
lib/yt/config.rb

Overview

Provides methods to read and write global configuration settings.

A typical usage is to set the API keys retrieved from the Google Developers Console.

Note that Yt.configure has precedence over values through with environment variables (see Models::Configuration).

Examples:

Set the API key for a server-only YouTube app:

Yt.configure do |config|
  config.api_key = 'ABCDEFGHIJ1234567890'
end

Set the API client id/secret for a web-client YouTube app:

Yt.configure do |config|
  config.client_id = 'ABCDEFGHIJ1234567890'
  config.client_secret = 'ABCDEFGHIJ1234567890'
end

Instance Method Summary collapse

Instance Method Details

#configurationYt::Models::Configuration

Returns the global Models::Configuration object.

While this method can be used to read and write configuration settings, it is easier to use #configure Yt.configure}.

Examples:

Yt.configuration.api_key = 'ABCDEFGHIJ1234567890'

Returns:



45
46
47
# File 'lib/yt/config.rb', line 45

def configuration
  @configuration ||= Yt::Configuration.new
end

#configure {|Yt::Models::Configuration| ... } ⇒ Object

Yields the global configuration to the given block.

Examples:

Yt.configure do |config|
  config.api_key = 'ABCDEFGHIJ1234567890'
end

Yields:



32
33
34
# File 'lib/yt/config.rb', line 32

def configure
  yield configuration if block_given?
end