++ed by:
Jeffrey Ray Hallock

NAME

Storm::Policy - Define how types are stored/retrieve from the database

SYNOPSIS

    package MyPolicy;
    use Storm::Policy;
    use Moose::Util::TypeConstraints;
    use DateTime::Format::SQLite;

    class_type 'DateTime',
        { class => 'DateTime' };

    define 'DateTime', 'DATETIME';

    transform 'DateTime',
        inflate { DateTime::Format::SQLite->parse_datetime( $_ ) },
        deflate { DateTime::Format::SQLite->format_datetime( $_ ) };


    # and then later

    $storm = Storm->new( source => ... , policy => 'MyPolicy' );
    

DESCRIPTION

The policy defines how data is stored in the database. Storm::Policy provides sugar for defining the data type for the DBMS and transforming values on inflation/deflation.

SUGAR

define $type, $dbms_type

define declares the data type to be used by the DBMS (Database Management Software) when storing values of the given $type.

transform inflate \&func, deflate \&func

transform is used to declare how values of the given type will be serialized when stored to the database. Using transformations can allow you to store complex objects.

The deflate function is used when storing value to the database. $_ is the value to be deflated, and the return value is what will be saved to the database.

The inflate function is used when retrieving the value from the database. $_ is the value to be inflated, and the return value is the value Storm will use.

AUTHOR

Jeffrey Ray Hallock <jeffrey.hallock at gmail dot com>

Modified from code in Dave Rolsky's Fey::ORM module.

COPYRIGHT

    Copyright (c) 2010 Jeffrey Ray Hallock. All rights reserved.
    This program is free software; you can redistribute it and/or
    modify it under the same terms as Perl itself.



Hosting generously
sponsored by Bytemark