Engine/Trait/WithRoles.pm

filter: Statementstmt 100% 45 / 45 Branchbran 66.6% 4 / 6 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 10 / 10 Podpod n/a totaltotal 90.9% 60 / 66 CC 5 SCAR 7.0
CC
5
Cov
93%
__ANON__
4.0
__ANON__
2.0
BEGIN
1.0
CRAP 2.0
↑ Summary Traits/WithRoles.pm »
1 package MooseX::Storage::Engine::Trait::WithRoles;
2 4 our $AUTHORITY = 'cpan:YANICK';
3 # ABSTRACT: An engine trait to include roles in serialization
4 4 $MooseX::Storage::Engine::Trait::WithRoles::VERSION = '0.2.0';
5 4 ▶use Moose::Util qw/ with_traits /;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 4 ▶use List::Util qw/ pairgrep /;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 4 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 4 ▶use MooseX::Storage::Base::SerializedClass;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 4 ▶use List::MoreUtils qw/ apply /;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 4 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 4 ▶around collapse_object => sub {
Subroutine __ANON__: called CC=4 SCAR=14.0
16 4 my( $orig, $self, @args ) = @_;
17  
18 4 my $packed = $orig->( $self, @args );
19  
20 4 my @extra;
21 4 ▶ ( $packed->{'__CLASS__'}, @extra ) = split '\|', ($self->object->meta->superclasses)[0]
Branch: 1 branch
BranchTrueFalseTotal
if $self->object->meta->is_anon_class or $self->object->meta->name =~ /__ANON__/ 4 0 4
Condition33%1/3
$self->object->meta->is_anon_class or $self->object->meta->name =~ /__ANON__/
l!l&&r!l&&!r
400
MC/DC0%0/2
$self->object->meta->is_anon_class or $self->object->meta->name =~ /__ANON__/
$self->object->meta->is_anon_class $self->object->meta->name =~ /__ANON__/
Truth table33%1/3
A or B
A= $self->object->meta->is_anon_classB= $self->object->meta->name =~ /__ANON__/
ABresult
1X1
011
000
22 if $self->object->meta->is_anon_class or $self->object->meta->name =~ /__ANON__/ ;
23  
24 4 my %in_superclass = map { $_ => 1 } map { split '\|', $_->name } @{ $packed->{'__CLASS__'}->meta->roles };
25  
26 4 ▶ if( my @roles = grep { !$in_superclass{$_} } map { split '\|', } ( @extra, map { $_->name } @{ $self->object->meta->roles } ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@roles) = grep({not $in_superclass{$_};} map({split(/\|/, $_, 0);} @extra, map({$_->name;} @{$self->object->meta->roles;})))) 4 0 4
27 5 ▶ @roles = apply {
Subroutine __ANON__: called CC=2 SCAR=6.9
28 5 ▶ $_ = { $_->meta->genitor->name => { pairgrep { $a ne '<<MOP>>' } %{ $_->meta->parameters } } }
Subroutine __ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
if $_->meta->isa("MooseX::Role::Parameterized::Meta::Role::Parameterized") 1 4 5
29 if $_->meta->isa('MooseX::Role::Parameterized::Meta::Role::Parameterized')
30 4 } @roles;
31 4 $packed->{'__ROLES__'} = \@roles;
32 }
33  
34  
35 4 return $packed;
36 4 };
37  
38 5 ▶around expand_object => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
39 5 my( $orig, $self, $data, @args ) = @_;
40  
41 5 $self->class(
42 MooseX::Storage::Base::SerializedClass::_unpack_class($data)
43 );
44  
45 5 $orig->($self,$data,@args);
46 4 };
47  
48 4 1;
49  
50 __END__
↑ Summary Traits/WithRoles.pm »