++ed by:

3 PAUSE users

Dominique Dumont
and 1 contributors


Config::Model::IdElementReference - Refer to id element(s) and extract keys


 # used from a value class
 element => [
            node_host => { type => 'leaf',
                           value_type => 'reference' ,
                           refer_to => '! host'
            if   => { type => 'leaf',
                      value_type => 'reference' ,
                      => { formula => '  ! host:$h if ',
                           variables => { 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*
                            => { type => 'check_list',
                                 refer_to => '- my_hash + - my_hash2   + - my_hash3'


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::HashId or the content of a Config::Model::ListId object.

This class is also used by Config::Model::CheckList to define the cheklist items from the keys of another hash (or content of a list).


Construction is handled by the calling object.

Config class parameters


refer_to is used to specify a hash element that will be used as a reference. 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).


When computed_refer_to is used, the path is computed using values from several elements in the configuration tree. computed_refer_to is a hash with 2 mandatory elements: formula and variables.

The available choice of this (computed or not) reference value is made from the available keys of the refered_to hash element or the values 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',
 computed_refer_to => { formula => '! host:$a lan', 
                        variables => { a => '- hostname' }

If you need to combine possibilities from several hash, use the "+" token to separate 2 paths:

 value_type => 'reference',
 computed_refer_to => { formula => '! host:$a lan + ! host:foobar lan', 
                        variables => { a => '- hostname' }

You can specify refer_to or computed_refer_to with a choice argument so the possible enum value will be the combination of the specified choice and the refered_to values.



Returns a human readable string with explains how is retrieved the reference. This method is mostly used to construct an error messages.


Dominique Dumont, (ddumont at cpan dot org)


Config::Model, Config::Model::Value, Config::Model::AnyId, Config::Model::CheckList