Dominique Dumont > Config-Model-0.640 > Config::Model::IdElementReference

Download:
Config-Model-0.640.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
Report a bug
Module Version: 1.0775   Source  

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' ,
                      computed_refer_to 
                      => { 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*
              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::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).

CONSTRUCTOR ^

Construction is handled by the calling object.

Config class parameters ^

refer_to

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).

computed_refer_to

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.

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