| 1 | package DBIx::Class::InflateColumn::TimePiece; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | # ABSTRACT: Auto-create Time::Piece objects from integer columns | ||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use v5.10; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use parent 'DBIx::Class'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 2 | ▶ | use Time::Piece; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 2 | our $VERSION = '0.02'; | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | sub register_column { | ||||||||||||||||||||||||||||
| 16 | 14 | ▶ | my ($self, $column, $info, @rest) = @_; | ||||||||||||||||||||||||||
|
Subroutine
register_column: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 14 | $self->next::method( $column, $info, @rest ); | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 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'}
| |||||||||||||||||||||||||||||
| 21 | 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'
| |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 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
| |||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | $self->inflate_column( | ||||||||||||||||||||||||||||
| 26 | $column => { | ||||||||||||||||||||||||||||
| 27 | inflate => sub { | ||||||||||||||||||||||||||||
| 28 | 6 | ▶ | my $dt = localtime shift; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 29 | 6 | return $dt; | |||||||||||||||||||||||||||
| 30 | }, | ||||||||||||||||||||||||||||
| 31 | deflate => sub { | ||||||||||||||||||||||||||||
| 32 | 6 | ▶ | return shift->epoch; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 33 | }, | ||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | 4 | ); | |||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 2 | 1; | |||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | __END__ | ||||||||||||||||||||||||||||