DBIx/Class/InflateColumn/ClassTypeEnum.pm

filter: Statementstmt 34.3% 11 / 32 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 37.5% 3 / 8 Podpod 100% 1 / 1 totaltotal 25.0% 15 / 60 CC 9 SCAR 25.3
CC
9
Cov
22%
register_column
30.0
__ANON__
6.0
__ANON__
6.0
CRAP 12.6
↑ Summary Class/Type/Enum.pm »
1 package DBIx::Class::InflateColumn::ClassTypeEnum;
2 # ABSTRACT: Inflate enum-like columns to your Class::Type::Enum classes
3 1 $DBIx::Class::InflateColumn::ClassTypeEnum::VERSION = '0.014';
4  
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10  
11  
12 0 ▶sub register_column {
Subroutine register_column: not called CC=5 SCAR=34.0
Pod documented
13 0 my ($self, $column, $info) = @_;
14 0 $self->next::method($column, $info);
15  
16 0 ▶ return unless $info->{extra} and my $class = $info->{extra}{enum_class};
Branch: 1 branch
BranchTrueFalseTotal
unless $info->{"extra"} and my $class = $info->{"extra"}{"enum_class"} 0 0 0
Condition0%0/3
$info->{"extra"} and my $class = $info->{"extra"}{"enum_class"}
!ll&&!rl&&r
000
MC/DC0%0/2
$info->{"extra"} and my $class = $info->{"extra"}{"enum_class"}
$info->{"extra"} my $class = $info->{"extra"}{"enum_class"}
Truth table0%0/3
A and B
A= $info->{"extra"}B= my $class = $info->{"extra"}{"enum_class"}
ABresult
0X0
100
111
17  
18 0 ▶ unless (eval { $class->isa('Class::Type::Enum') }) {
Branch: 1 branch
BranchTrueFalseTotal
unless (eval { do { $class->isa("Class::Type::Enum") } }) 0 0 0
19 0 Carp::croak "enum_class $class is not loaded or doesn't inherit from Class::Type::Enum";
20 }
21  
22 # I'd love to DTRT based on the column type but I think they're practically
23 # freeform in DBIC and just match the DB types, so that's a lot of
24 # possibilities...
25  
26 0 ▶ if ($info->{extra}{enum_ordinal_storage}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($info->{'extra'}{'enum_ordinal_storage'}) { } 0 0 0
27 $self->inflate_column(
28 $column => {
29 0 ▶ inflate => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
30 0 my ($ord) = @_;
31 0 ▶ return unless defined $ord;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $ord 0 0 0
32 0 $class->inflate_ordinal($ord);
33 },
34 0 ▶ deflate => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
35 0 my ($enum) = @_;
36 0 ▶ return unless defined $enum;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $enum 0 0 0
37 0 $enum->numify;
38 },
39 }
40 0 );
41  
42 }
43 else {
44 $self->inflate_column(
45 $column => {
46 0 ▶ inflate => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
47 0 my ($val) = @_;
48 0 ▶ return unless defined $val;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $val 0 0 0
49 0 $class->inflate_symbol($val);
50 },
51 0 ▶ deflate => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
52 0 my ($enum) = @_;
53 0 ▶ return unless defined $enum;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $enum 0 0 0
54 0 $enum->stringify;
55 },
56 }
57 0 );
58 }
59 }
60  
61  
62 1 1;
63  
64 __END__
↑ Summary Class/Type/Enum.pm »