Config::Model::Instance - Instance of configuration tree
my $model = Config::Model->new() ; $model ->create_config_class ( ... ) ; my $inst = $model->instance (root_class_name => 'SomeRootClass', instance_name => 'some_name');
This module provides an object that holds a configuration tree.
An instance object is created by calling instance method on an existing model:
my $inst = $model->instance (root_class_name => 'SomeRootClass', instance_name => 'test1');
The directory (or directories) holding configuration files is specified within the configuration model. For test purpose you can change the "root" directory with any of these parameters :
Pseudo root directory where to read the configuration files
Pseudo root directory where to write back the configuration files
Pseudo root directory where to read and write configuration files
Specify which backend to use. See "write_back ( ... )" for details
Note that all directory specified within the configuration model will be overridden.
all
I.e with write_root_dir => '~/mytest/, data read from /etc/foo.conf will be written back in ~/mytest/etc/foo.conf.
write_root_dir => '~/mytest/
/etc/foo.conf
~/mytest/etc/foo.conf
If you need to load configuration data that are not correct, you can use force_load => 1. Then, wrong data will be discarded.
force_load => 1
Returns the instance name.
Returns the root object of the configuration tree.
Destroy current configuration tree (with data) and returns a new tree with data loaded from disk.
Returns the model of the configuration tree.
All values stored in preset mode are shown to the user as default values. This feature is usefull to enter configuration data entered by an automatic process (like hardware scan)
Stop preset mode
Get preset mode
Tune Config::Model::Value to perform check on read (fetch) or write (store) or verify the value according to its value_type. The passed parameters are stacked. Parameters are :
Config::Model::Value
value_type
Skip write check.
Skip read check.
Skip value_type check (See Config::Model::Value for details). I.e Config::Model::Value will not enforce type checking.
Note that these values are stacked. They can be read by get_value_check until the next push_no_value_check or pop_no_value_check call.
Example:
$i->push_no_value_check('fetch') ; $i->push_no_value_check('fetch','type') ;
Pop off the check stack the last check set entered with push_no_value_check.
push_no_value_check
Read the check status. Returns 1 if a check is to be done. O if not. When used with the fetch_or_store parameter, returns a logical or or the check values, i.e. read_check || write_check
fetch_or_store
or
read_check || write_check
The data method provide a way to store some arbitrary data in the instance object.
Load configuration tree with configuration data. See Config::Model::Loader for more details
Returns an object dedicated to search an element in the configuration model (respecting privilege level).
This method returns a Config::Model::Searcher object. See Config::Model::Searcher for details on how to handle a search.
This method returns a Config::Model::WizardHelper object. See Config::Model::WizardHelper for details on how to create a wizard widget with this object.
wizard_helper arguments are explained in Config::Model::WizardHelper constructor arguments.
Usually, a program based on config model must first create the configuration model, then load all configuration data.
This feature enables you to declare with the model a way to load configuration data (and to write it back). See Config::Model::AutoRead for details.
Returns root directory where configuration data is read from.
Get the preferred backend method for this instance (as passed to the constructor).
Returns root directory where configuration data is written to.
Register a sub ref (with the backend name) that will be called with write_back method.
write_back
Try to run all subroutines registered with register_write_back to write the configuration informations until one succeeds (returns true). (See Config::Model::AutoRead for details).
register_write_back
You can specify here a pseudo root dir or another config dir to write configuration data back with root and config_dir parameters. This will override the model specifications.
root
config_dir
You can force to use a backend by specifying backend => xxx. For instance, backend => 'augeas' or backend => 'custom'.
backend => xxx
backend => 'augeas'
backend => 'custom'
You can force to use all backend to write the files by specifying backend => 'all'.
backend => 'all'
Dominique Dumont, (ddumont at cpan dot org)
Config::Model, Config::Model::Node, Config::Model::Loader, Config::Model::Searcher, Config::Model::Value,
To install Config::Model, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Config::Model
CPAN shell
perl -MCPAN -e shell install Config::Model
For more information on module installation, please visit the detailed CPAN module installation guide.