NAME

Podius::Property::Selection - component property allowing single selection from multiple choices


SYNOPSIS

  $property = new Podius::Property::Selection;

Supposed to be used in the Podius::Component manpage and the Podius::Property manpage module trees only.


DESCRIPTION

This module implements component property of multiple choices with single selection.

The selection is one code (scalar, often integer or short string) from list of possible codes.

If a constant array of choices is supplied in the class constructor, the label of this property is taken as a chosen code, when appropriate. If, instead, a constant code->label hash is supplied in the class constructor, it is used to translate from choice code to its label, when appropriate.

Note, access modifier method supposes to get a choice code as parameter, not label; access accessor method returns a choice code, not label. Use access_label instead. access_code is an alias to access.


REQUIREMENTS

the Exception manpage, the Podius::Property::Scalar manpage.


CONSTRUCTORS

new

description
Class constructor.

parameters
Class name, array or hash of choice codes and optional initial code (default is first).

returns
New formed property reference.


METHODS

access_label

description
This method is similar to access method inherited from superclass the Podius::Property::Scalar manpage, but choice label is used instead of choice code (code is evaluated from its label).

Accessor: returns the currently selected choice label.

Modifier: sets a new selected choice label. If the given label is not found, no changes done.

parameters
Accessor: none.

Modifier: choice label (string).

returns
Accessor: selected choice label (string).

Modifier: new selected choice code (scalar) or undef if the given label is not found.

access_all_codes

description
Only accessor form is available.

Returns a list of all possible choice codes.

returns
Array ref of scalars.

access_all_labels

description
Only accessor form is available.

Returns a list of all possible choice labels.

returns
Array ref of scalars.

access_all_code_labels

description
Only accessor form is available.

Returns a hash of all possible choices: {code =>* label}.

returns
Hash ref of scalar-to-scalar's.

access_initial_code

description
Only accessor form is available.

Returns a value that is used to initialized this property.

returns
Defined scalar.

access_is_reset

description
Only accessor form is available.

Returns true if the selected option is initial, see also access_initial_code method.

returns
Boolean.

reset

description
May be used to reset the selected option, see also access_initial_code method.

returns
This object itself.


ALIASES

access_code
An alias to access method.