Storm::Policy(3)
π Storm::Policy(3) π
okay bestie, you found it β this is Storm::Policy, a page from the User Contributed Perl Documentation, and it's literally the manual for telling Storm how your types get shoved into and yanked back out of a database. slay.
β¨ NAME β¨
Storm::Policy β defines how types are stored/retrieved from the database. that's it, that's the whole vibe. π
πΈ 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' );
look at her go π¦ she's just a little policy package and she's doing SO much.
π DESCRIPTION π
so, the policy is the thing that decides how data is stored in the database. Storm::Policy is basically sugar β sweet, sweet syntactic sugar π β that lets you declare the data type for the DBMS and transform values on inflation/deflation. two jobs. one icon. no cap.
π SUGAR π
define $type, $dbms_type
define declares the data type to be used by the DBMS (that's Database Management Software, iykyk) when storing values of the given $type. so you're like "hey bestie, this $type? it lives as $dbms_type in the database." periodt. π
transform inflate \&func, deflate \&func
transform is where you declare how values of the given type will be serialized when stored to the database. and here's the fun part β using transformations can allow you to store complex objects. yes really. the whole glow-up. β¨
- the
deflatefunction is used when storing a value to the database.$_is the value to be deflated, and the return value is what will be saved to the database. - the
inflatefunction 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.
lowkey the cleanest in/out pipeline ever. deflate on the way in, inflate on the way out. no notes. π
π«Ά AUTHOR π«Ά
Jeffrey Ray Hallock <jeffrey.hallock at gmail dot com>
modified from code in Dave Rolsky's Fey::ORM module. shoutout to the ancestors, fr fr π
π 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.
and that's the whole page, bestie π go forth and define your types.
this has been Storm::Policy(3), shipped as part of perl v5.42.0, dated 2025-07-25 β mwah, take care of her πβ¨
π¦ where this page comes from
- fedora 43: perl-Storm 0.240-34.fc43 Β· Artistic-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms