Config-Model

 view release on metacpan or  search on metacpan

lib/Config/Model/CheckList.pm  view on Meta::CPAN


Another checklist. In this case only the checked items of the other
checklist are available.

=back

This other hash or other checklist is indicated by the C<refer_to> or
C<computed_refer_to> parameter. C<refer_to> uses the syntax of the
C<steps> parameter of L<grab(...)|Config::Role::Grab/grab">

See L<refer_to parameter|Config::Model::IdElementReference/"refer_to parameter">.

=head2 Reference examples

=over

=item *

A check list where the available choices are the keys of C<my_hash>
configuration parameter:

 refer_to_list => {
     type => 'check_list',
     refer_to => '- my_hash'
 },

=item *

A check list where the available choices are the checked items of
C<other_check_list> configuration parameter:

 other_check_list => {
     type => 'check_list',
     choice => [qw/A B C/]
 },
 refer_to_list => {
     type => 'check_list',
     refer_to => '- other_check_list'
 },

=item *

A check list where the available choices are the keys of C<my_hash>
and C<my_hash2> and C<my_hash3> configuration parameter:

 refer_to_3_lists => {
     type => 'check_list',
     refer_to => '- my_hash + - my_hash2   + - my_hash3'
 },

=item *

A check list where the available choices are the specified choice and
the choice of C<refer_to_3_lists> and a hash whose name is specified
by the value of the C<indirection> configuration parameter (this
example is admittedly 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/],
 },

=back

=head1 Methods

=head2 get_type

Returns C<check_list>.

=head2 cargo_type

Returns 'leaf'.

=head2 check

Set choice. Parameter is either a list of choices to set or 
a list ref and some optional parameter. I.e:

  check (\@list, check => 'skip') ;

C<check> parameter decide on behavior in case of invalid
choice value: either die (if yes) or discard bad value (if skip)

=head2 uncheck

Unset choice. Parameter is either a list of choices to unset or 
a list ref and some optional parameter. I.e:

  uncheck (\@list, check => 'skip') ;

C<check> parameter decide on behavior in case of invalid
choice value: either die (if yes) or discard bad value (if skip)

=head2 is_checked

Parameters: C<< ( choice, [ check => yes|skip ] , [ mode => ... ]) >>

Return 1 if the given C<choice> was set. Returns 0 otherwise.

C<check> parameter decide on behavior in case of invalid
choice value: either die (if yes) or discard bad value (if skip)

C<mode> is either: custom standard preset default layered upstream_default

=head2 has_data

Return true if the check_list contains a set of checks different from default
or upstream default set of check.

=head2 get_choice

Returns an array of all items names that can be checked (i.e.
that can have value 0 or 1).



( run in 1.210 second using v1.01-cache-2.11-cpan-d7f47b0818f )