NAME
Config::Model::IdElementReference - Refer to id element(s) and extract keys
SYNOPSIS
# used from a value class
element => [
node_host => { type => 'leaf',
value_type => 'reference' ,
refer_to => '! host'
},
if => { type => 'leaf',
value_type => 'reference' ,
refer_to => [ ' ! host:$h if ', h => '- node_host' ]
},
],
# used from checklist
element => [
# simple reference, checklist items are given by the
# keys of my_hash
refer_to_list => { type => 'check_list',
refer_to => '- my_hash'
},
# checklist items are given by combining my_hash*
refer_to_2_list
=> { type => 'check_list',
refer_to => '- my_hash + - my_hash2 + - my_hash3'
},
]
DESCRIPTION
This class is user by Config::Model::Value to set up an enumerated value where the possible choice depends on the key of a Config::Model::AnyId object.
This class is also used by Config::Model::CheckList to define the cheklist items from the keys of another hash.
CONSTRUCTOR
Construction is handled by the calling object.
Config class parameters
refer_to parameter
refer_to
is used to spepify the hash element that will be used as a reference.
The first argument of
refer_to
points to an array or hash element in the configuration tree using the path syntax (See "grab" in Config::Model::Node for details). This path is treated like a computation formula. Hence it can contain variable and substitution like a computation formula.The following arguments of
refer_to
define the variable used in the path formula.The available choice of this reference value is made from the available keys of the refered_to hash element or the range of the refered_to array element.
The example means the the value must correspond to an existing host:
value_type => 'reference',
refer_to => '! host'
This example means the the value must correspond to an existing lan within the host whose Id is specified by hostname:
value_type => 'reference',
refer_to => ['! host:$a lan', a => '- hostname' ]
If you need to combine possibilities from several hash, use the "+
" token to separate 2 paths:
value_type => 'reference',
refer_to => ['! host:$a lan + ! host:foobar lan',
a => '- hostname' ]
You can specify refer_to
with a choice
argument so the possible enum value will be the combination of the specified choice and the refered_to values.
Methods
reference_info
Returns a human readable string with explains how is retrieved the reference. This method is mostly used to construct an error messages.
AUTHOR
Dominique Dumont, (ddumont at cpan dot org)
SEE ALSO
Config::Model, Config::Model::Value, Config::Model::AnyId, Config::Model::CheckList