| Config::Model::CheckList - Handle check list element |
cargo_type()
Config::Model::CheckList - Handle check list element
$model ->create_config_class ( ... element => [ check_list => { type => 'check_list', choice => [ 'A', 'B', 'C', 'D' ], help => { A => 'A effect is this', D => 'D does that', } }, check_list_refering_to_another_hash => { type => 'check_list', refer_to => '- foobar' },
]
) ;
This class provides a check list element for a the Config::Model::Node manpage. In other words, this class provides a list of booleans items. Each item can be set to 1 or 0.
The available items in the check list can be :
A fixed list (with the choice parameter)
A dynamic list where the available choise are the keys of another hash of the configuration tree. See Choice reference for details.
CheckList object should not be created directly.
A check list element must be declared with the following parameters:
Always checklist.
A list ref containing the check list items (optional)
This parameter is used when the keys of a hash are used to specify the
possible choices of the check list. refer_to point to a hash or list
element in the configuration tree. See Choice reference for
details. (optional)
Like refer_to, but use a computed value to find the hash or list
element in the configuration tree. See Choice reference for
details. (optional)
List ref to specify the check list items which are "on" by default. (optional)
Hash ref to provide informations on the check list items.
Used to provide dynamic modifications of the check list properties See the Config::Model::WarpedThing manpage for details
For example:
A simple check list with help:
choice_list
=> { type => 'check_list',
choice => ['A' .. 'Z'],
help => { A => 'A help', E => 'E help' } ,
},
A check list with default values:
choice_list_with_default
=> { type => 'check_list',
choice => ['A' .. 'Z'],
default_list => [ 'A', 'D' ],
},
A check list whose available choice and default change depending on
the value of the macro parameter:
'warped_choice_list'
=> { type => 'check_list',
warp => { follow => '- macro',
rules => { AD => { choice => [ 'A' .. 'D' ],
default_list => ['A', 'B' ] },
AH => { choice => [ 'A' .. 'H' ] },
}
}
},
The following methods returns the checklist parameter :
This other hash is indicated by the refer_to or
computed_refer_to parameter. refer_to uses the syntax of the
step parameter of grab(...)
See refer_to parameter.
A check list where the available choices are the keys of my_hash
configuration parameter:
refer_to_list
=> { type => 'check_list',
refer_to => '- my_hash'
},
A check list where the available choices are the keys of my_hash
and my_hash2 and my_hash3 configuration parameter:
refer_to_3_lists
=> { type => 'check_list',
refer_to => '- my_hash + - my_hash2 + - my_hash3'
},
A check list where the available choices are the specified choice and
the choice of refer_to_3_lists and a hash whose name is specified
by the value of the indirection configuration parameter (this
example is admitedly convoluted):
refer_to_check_list_and_choice
=> { type => 'check_list',
computed_refer_to => { formula => '- refer_to_2_list + - $var',
variables { 'var' => '- indirection ' }
},
choice => [qw/A1 A2 A3/],
},
Returns check_list.
cargo_type()Returns 'leaf'.
Set choice.
Unset choice
Returns an array of all items names that can be checked (i.e. that can have value 0 or 1).
Return the help string on this choice value
Reset the check list (all items are set to 0)
Returns a hash (or a hash ref) of all items. The boolean value is the value of the hash.
Example:
{ A => 0, B => 1, C => 0 , D => 1}
By default, this method will return all items set by the user, or items set in preset mode or checked by default.
With a parameter, this method will return either:
The list entered by the user
The list entered in preset mode
The list set in preset mode or checked by default.
The default list (defined by the configuration model)
Returns a list (or a list ref) of all checked items (i.e. all items set to 1).
Returns a string listing the checked items (i.e. "A,B,C")
Set all passed items to checked (1). All other available items in the check list are set to 0.
Example:
# set cl to A=0 B=1 C=0 D=1
$cl->set_checked_list('B','D')
Set check_list items. Missing items in the paramaters are set to 0.
The example ( A => 1, B => 1 ) above will give :
A = 1 , B = 1, C = 0 , D = 0
Load check_list as an array ref. Data is simply forwarded to set_checked_list.
Dominique Dumont, (ddumont at cpan dot org)
the Config::Model manpage, the Config::Model::Instance manpage, the Config::Model::Node manpage, the Config::Model::AnyId manpage, the Config::Model::ListId manpage, the Config::Model::HashId manpage, the Config::Model::Value manpage
| Config::Model::CheckList - Handle check list element |