| 1 | package DBIx::Class::InflateColumn::TimePiece; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | # ABSTRACT: Auto-create Time::Piece objects from integer (number of seconds since epoch) columns | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use v5.10; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 2 | our $VERSION = '0.03'; # VERSION | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 2 | ▶ | use parent 'DBIx::Class'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 2 | ▶ | use Time::Piece; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 14 | ▶ | sub register_column { | ||||||||||||||||||||||||||
|
Subroutine
register_column: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 17 | 14 | my ($self, $column, $info, @rest) = @_; | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 14 | $self->next::method( $column, $info, @rest ); | |||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 14 | ▶ | my $data_type = $info->{data_type} || ''; | ||||||||||||||||||||||||||
|
Condition100%2/2
$info->{'data_type'} || ''
MC/DC100%1/1
$info->{'data_type'} || ''
$info->{'data_type'}
Truth table100%2/2
A
A= $info->{'data_type'}
| |||||||||||||||||||||||||||||
| 22 | 14 | ▶ | my $is_integer = $data_type eq 'integer' || $data_type eq 'int'; | ||||||||||||||||||||||||||
|
Condition100%3/3
$data_type eq 'integer' || $data_type eq 'int'
MC/DC100%2/2
$data_type eq 'integer' || $data_type eq 'int'
$data_type eq 'integer'
$data_type eq 'int'
Truth table100%3/3
A || B
A= $data_type eq 'integer'B= $data_type eq 'int'
| |||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 14 | ▶ | return if !$info->{inflate_time_piece} || !$is_integer; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$info->{"inflate_time_piece"} and $is_integer
MC/DC100%2/2
$info->{"inflate_time_piece"} and $is_integer
$info->{"inflate_time_piece"}
$is_integer
Truth table100%3/3
A and B
A= $info->{"inflate_time_piece"}B= $is_integer
| |||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | $self->inflate_column( | ||||||||||||||||||||||||||||
| 27 | $column => { | ||||||||||||||||||||||||||||
| 28 | 6 | ▶ | inflate => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 29 | 6 | my $dt = localtime shift; | |||||||||||||||||||||||||||
| 30 | 6 | return $dt; | |||||||||||||||||||||||||||
| 31 | }, | ||||||||||||||||||||||||||||
| 32 | 6 | ▶ | deflate => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 33 | 6 | return shift->epoch; | |||||||||||||||||||||||||||
| 34 | }, | ||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||
| 36 | 4 | ); | |||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 2 | 1; | |||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | __END__ | ||||||||||||||||||||||||||||