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:

  • (Yt::Models::Configuration)

    The global configuration.


47
48
49
# File 'lib/yt/config.rb', line 47

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:

  • (Yt::Models::Configuration)

    The global configuration.


34
35
36
# File 'lib/yt/config.rb', line 34

def configure
  yield configuration if block_given?
end