Base/SerializedClass.pm

filter: Statementstmt 100% 38 / 38 Branchbran 100% 4 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 10 / 10 Podpod 0.0% 0 / 1 totaltotal 98.1% 52 / 53 CC 3 SCAR 2.9
CC
3
Cov
100%
_unpack_class
2.0
__ANON__
2.0
BEGIN
1.0
CRAP 1.3
« Traits/WithRoles.pm ↑ Summary
1 package MooseX::Storage::Base::SerializedClass;
2 5 our $AUTHORITY = 'cpan:YANICK';
3 # ABSTRACT: Deserialize according to the serialized __CLASS__
4 5 $MooseX::Storage::Base::SerializedClass::VERSION = '0.2.0';
5  
6 5 ▶use parent 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 5 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 5 with 'MooseX::Storage::Basic';
11  
12 5 ▶use Moose::Util qw/ with_traits /;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 5 ▶use Class::Load 'load_class';
Subroutine BEGIN: called CC=1 SCAR=0.0
14 5 ▶use List::MoreUtils qw/ apply /;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 5 our @EXPORT_OK = qw/ moosex_unpack /;
17  
18 5 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 5 ▶around unpack => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
21 5 my( $orig, $class, $data, %args ) = @_;
22  
23 5 $class = _unpack_class( $data );
24  
25 5 $orig->($class,$data,%args);
26 5 };
27  
28 13 ▶sub _unpack_class {
Subroutine _unpack_class: called CC=2 SCAR=6.9
29 13 my $data = shift;
30  
31 13 my $class = Class::Load::load_class( $data->{'__CLASS__'} );
32  
33 13 ▶ if( my $roles = delete $data->{'__ROLES__'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $roles = delete $data->{"__ROLES__"}) 3 10 13
34 3 ▶ my @roles = apply {
Subroutine __ANON__: called CC=2 SCAR=6.9
35 3 ▶ if( my( $c, $params ) = eval { %$_} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = eval { do { %$_ } }) 1 2 3
36 1 $_ = $c->meta->generate_role( parameters => $params );
37 }
38 3 } @$roles;
39  
40 3 $class = with_traits( $class, @roles );
41 }
42  
43 13 return $data->{'__CLASS__'} = $class;
44 }
45  
46 3 ▶sub moosex_unpack {
Subroutine moosex_unpack: called CC=1 SCAR=0.0
Pod undocumented
47 3 my $data = shift;
48 3 _unpack_class($data)->unpack($data);
49 }
50  
51 5 1;
52  
53 __END__
« Traits/WithRoles.pm ↑ Summary