Class Loquacious::Configuration
In: lib/loquacious/configuration.rb
lib/loquacious/configuration/help.rb
lib/loquacious/configuration/iterator.rb
Parent: Object

A Configuration provides a "blank slate" for storing configuration properties along with descriptions and default values. Configurations are accessed by name, and hence, the configuration properties can be retrieved from any location in your code.

Each property has an associated description that can be displayed to the user via the Configuration::Help class. This is the main point of the Loquacious library - tell the user what all yoru configruation properties actually do!

Each configurationp property can also have a default value that is returned if no value has been set for that property. Each property should hae a sensible default - the user should not have to configure every property in order to use a piece of code.

Methods

[]   []=   __eigenclass_eval   __send   defaults_for   for   help_for   merge!   method_missing   new   obj   to_hash   to_hash   undefined?  

Classes and Modules

Class Loquacious::Configuration::DSL
Class Loquacious::Configuration::Help
Class Loquacious::Configuration::Iterator

External Aliases

help_for -> help

Attributes

__defaults  [R]  Accessor for configuration defaults
__defaults_mode  [RW]  Flag to switch the configuration object into defaults mode. This allows default values to be set instead regular values.
__desc  [R]  Accessor for the description hash.
__values  [R]  Accessor for configuration values

Public Class methods

Set the default values for the configuration associated with the given name. A block is required by this method.

Default values do not interfere with normal configuration values. If both are defined for a particualr configruation setting, then the regular configuration value will be returned.

Defaults allow the user to define configuration values before the library defaults have been loaded. They prevent library defaults from overriding user settings.

Returns the configuration associated with the given name. If a block is given, then it will be used to create the configuration.

The same name can be used multiple times with different configuration blocks. Each different block will be used to add to the configuration; i.e. the configurations are additive.

Returns a Help instance for the configuration associated with the given name. See the Help#initialize method for the options that can be used with this method.

Create a new configuration object and initialize it using an optional block of code.

Recursively convert a configuration object to a hash.

Public Instance methods

Provides hash accessor notation for configuration values.

  config = Configuration.for('app') {
             port  1234
           }
  config[:port]  #=> 1234
  config.port    #=> 1234

Provides hash accessor notation for configuration values.

  config = Configuration.for('app')
  config[:port] = 8808
  config.port            #=> 8808

Evaluate the given code string in the context of this object‘s eigenclass (singleton class).

Only invoke public methods on the Configuration instances.

Merge the contents of the other configuration into this one. Values from the other configuratin will overwite values in this configuration.

This function is recursive. Nested configurations will be merged with their counterparts in the other configuration.

When invoked, an attribute reader and writer are defined for the method. Any arguments given are used to set the value of the attributes. If a block is given, then the attribute is a nested configuration and the block is evaluated in the context of a new configuration object.

Recursively convert the configuration object to a hash.

[Validate]