| 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
| |||||||||||
| 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
| |||||||||||
| 44 | 2 | $INFLATE{$type}->{$name} = $hash->{$type}; | |||||||||
| 45 | } | ||||||||||
| 46 | } | ||||||||||
| 47 | } | ||||||||||
| 48 | |||||||||||
| 49 | 2 | 1; | |||||||||