Model/Schema/Inflate.pm

filter: Statementstmt 87.8% 29 / 33 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 66.6% 8 / 12 Podpod 0.0% 0 / 3 totaltotal 75.0% 39 / 52 CC 4 SCAR 7.4
CC
4
Cov
84%
inflate_type
4.1
__ANON__
2.0
__ANON__
2.0
CRAP 2.1
« Model/Row.pm ↑ Summary Model/Accessor.pm »
1 package Data::Model::Schema::Inflate;
2 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 2 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 $Carp::Internal{(__PACKAGE__)}++;
7  
8 3 ▶sub import {
Subroutine import: called CC=1 SCAR=0.0
9 3 my $class = shift;
10 3 my $caller = caller;
11  
12 2 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
13 3 *{"$caller\::inflate_type"} = \&inflate_type;
14 }
15  
16 my %INFLATE = (
17 inflate => {
18 0 ▶ URI => sub { URI->new($_[0]) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
19 0 ▶ Hex => sub { unpack("H*", $_[0]) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
20 },
21 deflate => {
22 0 ▶ URI => sub { $_[0]->as_string },
Subroutine __ANON__: not called CC=1 SCAR=6.9
23 0 ▶ Hex => sub { pack("H*", $_[0]) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
24 },
25 2 );
26  
27 1 ▶sub get_inflate {
Subroutine get_inflate: called CC=1 SCAR=0.0
Pod undocumented
28 1 my($class, $name) = @_;
29 1 $INFLATE{inflate}->{$name};
30 }
31  
32 1 ▶sub get_deflate {
Subroutine get_deflate: called CC=1 SCAR=0.0
Pod undocumented
33 1 my($class, $name) = @_;
34 1 $INFLATE{deflate}->{$name};
35 }
36  
37 1 ▶sub inflate_type {
Subroutine inflate_type: called CC=4 SCAR=14.2
Pod undocumented
38 1 my($name, $hash) = @_;
39 1 my $caller = caller;
40 1 for my $type (qw/ inflate deflate /) {
41 2 ▶ if (ref($hash->{$type}) eq 'CODE') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $hash->{$type} eq "CODE") 2 0 2
42 Carp::croak "The inflate_type '$name' has already been created, cannot be created again in $caller"
43 2 ▶ if $INFLATE{$type}->{$name};
Branch: 1 branch
BranchTrueFalseTotal
if $INFLATE{$type}{$name} 0 2 2
44 2 $INFLATE{$type}->{$name} = $hash->{$type};
45 }
46 }
47 }
48  
49 2 1;
« Model/Row.pm ↑ Summary Model/Accessor.pm »