DESCRIPTION

This module provides a boolean data type for use with Class::Meta attributes. Simply load it, then pass "boolean" (or the alias "bool") to the add_attribute() method of a Class::Meta object to create an attribute of the boolean data type. See Class::Meta::Type for more information on using and creating data types.

Accessors

Although the boolean data type has both "default" and "affordance" accessor options available, unlike the other data types that ship with Class::Meta, they have different implementations. The reason for this is to ensure that the value of a boolean attribute is always 0 or 1.

For the "default" accessor style, there is no difference in the interface from the default accessors for other data types. The default accessor merely checks the truth of the new value, and assigns 1 if it's a true value, and 0 if it's a false value. The result is an efficient accessor that maintains the consistency of the data.

For the "affordance" accessor style, however, the boolean data type varies in the accessors it creates. For example, for a boolean attributed named "alive", instead of creating the get_alive and set_alive accessors common to other affordance-style accessors, it instead creates three:

is_alive

set_alive_on

set_alive_off

The result is highly efficient accessors that ensure the integrity of the data without the overhead of validation checks.