class Webgen::Configuration
Stores the configuration for a webgen website.
Configuration
options can be created by using the define_option
method:
config.define_option "my.new.option", 'default value'
and later accessed or set using the accessor methods []
and []=
. A validation block can also be specified when defining an option. This validation block is called when a new value should be set and it should return the (possibly changed) value to be set:
config.define_option "my.new.option", 'default value' do |val| raise "Option must be a string" unless val.kind_of?(String) val.upcase end
*Note*: When a Configuration
object is dumped (via Marshal), the option validator procs are not dumped and can therefore not be restored!
Attributes
Contains all the defined configuration options.
Public Class Methods
Create a new Configuration
object.
Public Instance Methods
Return the value for the configuration option name
.
Use value
as value for the configuration option name
.
Define a new option name
with a default value of default
.
If a validation block is provided, it is called with the new value when one is set and should return a (possibly altered) value to be set.
Load the configuration values.
If filename
is a String, it is treated as the name of the configuration file from which the values should be loaded. If filename
responds to #read, it is treated as an IO object from which the values should be loaded.
The configuration needs to be in YAML format. More specifically, it needs to contain a YAML hash which is further processed by set_values
.
Returns an array with all unknown configuration options.
Return true
if the given option exists.
Set the configuration values from the Hash
values
.
The hash can either contain full configuration option names or namespaced option names, ie. in YAML format:
my.option: value website: lang: en url: my_url
The above hash will set the option 'my.option' to value
, 'website.lang' to en
and 'website.url' to my_url
.
Returns an array with all unknown configuration options.