Dominique Dumont > Config-Model > Config::Model::CheckList

Download:
Config-Model-0.640.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
Report a bug
Module Version: 1.0978   Source  

NAME ^

Config::Model::CheckList - Handle check list element

SYNOPSIS ^

 $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'
          },

      ]
  ) ;

DESCRIPTION ^

This class provides a check list element for a Config::Model::Node. 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 :

CONSTRUCTOR ^

CheckList object should not be created directly.

CheckList model declaration ^

A check list element must be declared with the following parameters:

type

Always checklist.

choice

A list ref containing the check list items (optional)

refer_to

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)

computed_refer_to

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)

default_list

List ref to specify the check list items which are "on" by default. (optional)

help

Hash ref to provide informations on the check list items.

warp

Used to provide dynamic modifications of the check list properties See Config::Model::WarpedThing for details

For example:

Introspection methods ^

The following methods returns the checklist parameter :

refer_to
computed_refer_to

Choice reference ^

The choice items of a check_list can be given by another configuration element. This other element can be:

This other hash or other checklist 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.

Reference examples

Methods ^

get_type

Returns check_list.

cargo_type()

Returns 'leaf'.

check ( $choice )

Set choice.

uncheck ( choice )

Unset choice

is_checked( choice )

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

get_choice

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

get_help (choice_value)

Return the help string on this choice value

clear

Reset the check list (all items are set to 0) (can also be called as clear_values)

get_checked_list_as_hash ( [ custom | preset | standard | default ] )

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:

custom

The list entered by the user

preset

The list entered in preset mode

standard

The list set in preset mode or checked by default.

default

The default list (defined by the configuration model)

upstream_default

The list implemented by upstream project (defined in the configuration model)

get_checked_list ( [ custom | preset | standard | default ] )

Returns a list (or a list ref) of all checked items (i.e. all items set to 1).

fetch ( [ custom | preset | standard | default ] )

Returns a string listing the checked items (i.e. "A,B,C")

get( path [, custom | preset | standard | default ])

Get a value from a directory like path.

set( path , value )

Set a value with a directory like path.

set_checked_list ( item1, item2, ..)

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_checked_list_as_hash ( A => 1, B => 1 )

Set check_list items. Missing items in the given list of parameters are set to 0.

The example ( A => 1, B => 1 ) above will give :

 A = 1 , B = 1, C = 0 , D = 0

load_data ( list_ref )

Load check_list as an array ref. Data is simply forwarded to set_checked_list.

Ordered checklist methods ^

All the methods below are valid only for ordered checklists.

swap ( choice_a, choice_b) ^

Swap the 2 given choice in the list. Both choice must be already set.

move_up ( choice ) ^

Move the choice up in the checklist.

move_down ( choice ) ^

Move the choice down in the checklist.

AUTHOR ^

Dominique Dumont, (ddumont at cpan dot org)

SEE ALSO ^

Config::Model, Config::Model::Instance, Config::Model::Node, Config::Model::AnyId, Config::Model::ListId, Config::Model::HashId, Config::Model::Value