NAME

Coat::Persistent::Types

DESCRIPTION

This module provides a set of types and coercions that are of common use when dealing with an database.

By loading this module you are able to use all the types defined here for your attribute definitions (either for the 'isa' option or fore the 'store_as' one).

TYPES

UnixTimestamp

An Int that is strictly greater than 0 and that represent the time since 1970-01-01 00:00:01

Date

A string representing the date with the following format: YYYY-MM-DD

DateTime

COERCIONS

All the types defined are coerceable from the type UnixTimestamp and the type UnixTimestamp can be coerced to all the types defined.

EXAMPLE

package Stuff;

use Coat::Persistent::Types;

# we have a date field, we want to store it and to handle it as string
# formated like YYYY-MM-DD
has_p birth_date => (
    is => 'ro',
    isa => 'Date',
);

# we have a datetime that's changed whenever the object si touched.
# we want to handle the data as a timestamp, and to store it as DateTime string.
has_p last_update => (
    is => 'rw',
    isa => 'UnixTimestamp',
    store_as => 'DateTime',
);

# or if you'd rather have a Class::Date object than a UnixTimestamp :
has_p last_update => (
    is => 'rw',
    isa => 'Class::Date',
    store_as => 'DateTime',
);
Class::Date

All the types defined in this module are coerceable from or to the type UnixTimestamp.

SEE ALSO

Coat::Types Coat::Persistent::Types::

AUTHOR

Alexis Sukrieh <sukria@cpan.org> http://www.sukria.net

1 POD Error

The following errors were encountered while parsing the POD:

Around line 126:

'=item' outside of any '=over'