|
define DateTime, 'DATETIME' ;
storm_table( 'Bazzle' );
has 'identifier' => ( is => 'rw' , traits => [ qw( PrimaryKey AutoIncrement ) ] );
has 'date' => (
is => 'rw' ,
isa => DateTime,
transform => {
inflate => sub { DateTime::Format::SQLite->parse_datetime( $_ ) },
deflate => sub { DateTime::Format::SQLite->format_datetime( $_ ) },
}
);
my $storm = Storm->new( source => [ 'DBI:SQLite:dbname=:memory:' ], policy => 'MyPolicy' );
$storm ->aeolus->install_class( 'Bazzle' );
my $o = Bazzle->new( date => DateTime->now );
$storm ->insert( $o );
$o = $storm ->lookup( 'Bazzle' , $o ->identifier );
isa_ok $o ->date, 'DateTime' , 'inflated date attribute' ;
|