Class | Loquacious::Configuration |
In: |
lib/loquacious/configuration.rb
lib/loquacious/configuration/iterator.rb lib/loquacious/configuration/help.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.
help_for | -> | help |
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.
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
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.