1Storm::Policy(3)      User Contributed Perl Documentation     Storm::Policy(3)
2
3
4

NAME

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

SYNOPSIS

9           package MyPolicy;
10           use Storm::Policy;
11           use Moose::Util::TypeConstraints;
12           use DateTime::Format::SQLite;
13
14           class_type 'DateTime',
15               { class => 'DateTime' };
16
17           define 'DateTime', 'DATETIME';
18
19           transform 'DateTime',
20               inflate { DateTime::Format::SQLite->parse_datetime( $_ ) },
21               deflate { DateTime::Format::SQLite->format_datetime( $_ ) };
22
23
24           # and then later
25
26           $storm = Storm->new( source => ... , policy => 'MyPolicy' );
27

DESCRIPTION

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

SUGAR

34       define $type, $dbms_type
35           "define" declares the data type to be used by the DBMS (Database
36           Management Software) when storing values of the given $type.
37
38       transform inflate \&func, deflate \&func
39           "transform" is used to declare how values of the given type will be
40           serialized when stored to the database. Using transformations can
41           allow you to store complex objects.
42
43           The "deflate" function is used when storing value to the database.
44           $_ is the value to be deflated, and the return value is what will
45           be saved to the database.
46
47           The "inflate" function is used when retrieving the value from the
48           database.  $_ is the value to be inflated, and the return value is
49           the value Storm will use.
50

AUTHOR

52       Jeffrey Ray Hallock <jeffrey.hallock at gmail dot com>
53
54       Modified from code in Dave Rolsky's Fey::ORM module.
55
57           Copyright (c) 2010 Jeffrey Ray Hallock. All rights reserved.
58           This program is free software; you can redistribute it and/or
59           modify it under the same terms as Perl itself.
60
61
62
63perl v5.34.0                      2021-07-22                  Storm::Policy(3)
Impressum