X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FDateTime%2FEpoch.pm;h=f0f74b3c4c88bb1d1ff9aa2299f8ba41645334b0;hb=0a389a2c7e26f2bc44ff5518acda959f29205885;hp=395fe9400f391ec3ddc447fe6037ca0da99e4ced;hpb=a60991d6a1ba7ae14d9451727a98351fb81f5b0d;p=dbsrgits%2FDBIx-Class-DateTime-Epoch.git diff --git a/lib/DBIx/Class/DateTime/Epoch.pm b/lib/DBIx/Class/DateTime/Epoch.pm index 395fe94..f0f74b3 100644 --- a/lib/DBIx/Class/DateTime/Epoch.pm +++ b/lib/DBIx/Class/DateTime/Epoch.pm @@ -3,7 +3,7 @@ package DBIx::Class::DateTime::Epoch; use strict; use warnings; -our $VERSION = '0.03'; +our $VERSION = '0.04'; use base qw( DBIx::Class ); @@ -79,36 +79,34 @@ even if it has been already set. =back -=head1 AUTHOR +=head1 AUTHORS -=over 4 - -=item * Brian Cassidy Ebricas@cpan.orgE - -=item * Adam Paynter Eadapay@cpan.orgE +Brian Cassidy Ebricas@cpan.orgE -=back +Adam Paynter Eadapay@cpan.orgE =head1 COPYRIGHT AND LICENSE -Copyright 2006 by Brian Cassidy +Copyright 2007 by Brian Cassidy This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut -__PACKAGE__->mk_classdata( ctime_columns => [ ] ); -__PACKAGE__->mk_classdata( mtime_columns => [ ] ); +__PACKAGE__->mk_classdata( ctime_columns => [] ); +__PACKAGE__->mk_classdata( mtime_columns => [] ); sub register_column { - my( $class, $col, $info ) = @_; + my ( $class, $col, $info ) = @_; $class->next::method( $col, $info ); - - if( my $type = $info->{ epoch } ) { - $class->ctime_columns( [ @{ $class->ctime_columns }, $col ] ) if $type eq 'ctime'; - $class->mtime_columns( [ @{ $class->mtime_columns }, $col ] ) if $type eq 'mtime'; - + + if ( my $type = $info->{ epoch } ) { + $class->ctime_columns( [ @{ $class->ctime_columns }, $col ] ) + if $type eq 'ctime'; + $class->mtime_columns( [ @{ $class->mtime_columns }, $col ] ) + if $type eq 'mtime'; + $class->inflate_column( $col => { inflate => sub { DateTime->from_epoch( epoch => shift ) }, @@ -121,7 +119,7 @@ sub register_column { sub insert { my $self = shift; my $time = time; - + for my $column ( @{ $self->ctime_columns }, @{ $self->mtime_columns } ) { next if defined $self->get_column( $column ); $self->store_column( $column => $time ); @@ -139,7 +137,7 @@ sub update { next if exists $dirty{ $column }; $self->set_column( $column => $time ); } - + $self->next::method( @_ ); }