Storm::Policy - Define how types are stored/retrieve from the database
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' );
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.
define declares the data type to be used by the DBMS (Database Management Software) when storing values of the given $type.
define
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.
transform
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.
deflate
$_
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.
inflate
Jeffrey Ray Hallock <jeffrey.hallock at gmail dot com>
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.
To install Storm, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Storm
CPAN shell
perl -MCPAN -e shell install Storm
For more information on module installation, please visit the detailed CPAN module installation guide.