The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Config::Model::AnyThing - Base class for configuration tree item

SYNOPSIS

 package Config::Model::SomeThing ;
 use base qw/Config::Model::AnyThing/ ;

DESCRIPTION

This class must be inherited by all nodes or leaves of the configuration tree.

AnyThing provides some methods and no constructor.

Introspection methods

element_name()

Returns the element name that contain this object.

index_value()

For object stored in an array or hash element, returns the index (or key) containing this object.

parent()

Returns the node containing this object. May return undef if parent() is called on the root of the tree.

location()

Returns the node location in the configuration tree. This location conforms with the syntax defined by "grab()" method.

Information management

grab(...)

Grab an object from the configuration tree. The parameter is a string indicating the steps to follow in the tree to find the required item.

The steps are made of the following items separated by spaces:

-

Go up one node

!

Go to the root node.

xxx

Go down using xxx element.

xxx:yy

Go down using xxx element and id yy (valid for hash or list elements)

?xxx

Go up the tree until a node containing element xxx is found. Then go down the tree like item xxx.

If ?xxx:yy, go up the tree the same way. But no check is done to see if id yy actually exists or not. Only the element xxx is considered when going up the tree.

xxx%yy

Like xxx:yy, but does not create id yy for element xxx. I.e. grab will fail if the id yy does not already exsits in element xxx

grab_value(...)

Like "grab(...)", but will return the value of a leaf object, not just the leaf object.

Will raise an exception if following the steps ends on anything but a leaf.

grab_root()

Returns the root of the configuration tree.

AUTHOR

Dominique Dumont, domi@komarr.grenoble.hp.com

SEE ALSO

Config::Model, Config::Model::Instance, Config::Model::Node, Config::Model::Loader, Config::Model::Dumper