Module: Yt::Config

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

Overview

Note:

Config is the only module auto-loaded in the Yt module, in order to have a syntax as easy as Yt.configure

Provides methods to read and write runtime configuration information.

Configuration options are loaded from ‘~/.yt`, `.yt`, command line switches, and the `YT_OPTS` environment variable (listed in lowest to highest precedence).

Examples:

A server-to-server YouTube client app


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

A web YouTube client app


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

Instance Method Summary collapse

Instance Method Details

#configurationObject

Returns the global [Configuration](Yt/Configuration) object. While you can use this method to access the configuration, the more common convention is to use [Yt.configure](Yt#configure-class_method).

Examples:

Yt.configuration.api_key = 'ABCDEFGHIJ1234567890'

See Also:



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

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

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

Yields the global configuration to a block.

Examples:

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

Yields:

See Also:



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

def configure
  yield configuration if block_given?
end