NAME

Statocles::Types - Type constraints and coercions for Statocles

SYNOPSIS

    use Statocles::Class;
    use Statocles::Types qw( :all );

    has store => (
        isa => Store,
        coerce => Store->coercion,
    );

    has theme => (
        isa => Theme,
        coerce => Theme->coercion,
    );

    has link => (
        isa => LinkType,
        coerce => LinkType->coercion,
    );
    has links => (
        isa => LinkArray,
        coerce => LinkArray->coercion,
    );
    has nav => (
        isa => LinkHash,
        coerce => LinkHash->coercion,
    );

    has date => (
        isa => DateTimeObj,
        coerce => DateTimeObj->coercion,
    );

    has path => (
        isa => PagePath,
        coerce => PagePath->coercion,
    );

DESCRIPTION

This is a type library for common Statocles types.

TYPES

Store

A Statocles::Store object.

This can be coerced from any Path::Tiny object or any String, which will be used as the filesystem path to the store's documents (the path attribute). The coercion creates a Statocles::Store object.

Theme

A Statocles::Theme object.

This can be coerced from any Path::Tiny object or any String, which will be used as the store attribute (which will then be given to the Store's path attribute).

LinkType

A Statocles::Link object.

This can be coerced from any HashRef.

LinkArray

An arrayref of Statocles::Link objects.

This can be coerced from any ArrayRef of HashRefs.

LinkHash

A hashref of arrayrefs of Statocles::Link objects. Useful for the named links like site navigation.

This can be coerced from any HashRef of ArrayRef of HashRefs.

DateTimeObj

A DateTime::Moonpig object representing a date/time. This can be coerced from a YYYY-MM-DD string or a YYYY-MM-DD HH:MM:SS string.

PagePath

A Mojo::Path object representing the path portion of a URL. It can be coerced from a suitable string.