Attributes/Trait/Role/Application/ToRole.pm

filter: Statementstmt 90.4% 19 / 21 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod n/a totaltotal 89.6% 26 / 29 CC 2 SCAR 3.2
CC
2
Cov
87%
__ANON__
2.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.4
« Attributes/Trait/Role.pm ↑ Summary Attributes/Trait/Role/Application/ToClass.pm »
1 #
2 # This file is part of MooseX-TrackDirty-Attributes
3 #
4 # This software is Copyright (c) 2011 by Chris Weyl.
5 #
6 # This is free software, licensed under:
7 #
8 # The GNU Lesser General Public License, Version 2.1, February 1999
9 #
10 package MooseX::TrackDirty::Attributes::Trait::Role::Application::ToRole;
11 9 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
12 9 $MooseX::TrackDirty::Attributes::Trait::Role::Application::ToRole::AUTHORITY = 'cpan:RSRCHBOY';
13 }
14 9 $MooseX::TrackDirty::Attributes::Trait::Role::Application::ToRole::VERSION = '2.003';
15 # ABSTRACT: Application to role helper trait
16  
17 9 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 9 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 9 ▶use Moose::Util::MetaRole;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 9 ▶use MooseX::TrackDirty::Attributes::Util ':all';
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 # debug...
23 #use Smart::Comments;
24  
25  
26 1 ▶around apply => sub {
Subroutine __ANON__: called CC=2 SCAR=8.4
27 1 my ($next, $self, $role1, $role2) = @_;
28  
29 ### role1 (source): $role1->name
30 ### role2 (target): $role2->name
31  
32 1 $self->$next(
33 $role1,
34 Moose::Util::MetaRole::apply_metaroles(
35 for => $role2,
36 role_metaroles => {
37 role => [ trait_for 'Role' ],
38 application_to_class => [ ToClass ],
39 application_to_role => [ __PACKAGE__ ],
40 application_to_instance => [ ToInstance ],
41 },
42 ),
43 );
44  
45 ### check to see if our target now does the native trait...
46 return
47 1 ▶ unless $role2->does_role('Moose::Meta::Attribute::Native::Trait');
Branch: 1 branch
BranchTrueFalseTotal
unless $role2->does_role("Moose::Meta::Attribute::Native::Trait") 1 0 1
48  
49 ### applying TrackDirtyNativeTrait to: $role2->name
50 0 TrackDirtyNativeTrait->meta->apply($role2);
51 0 return;
52 9 };
53  
54 9 !!42;
55  
56 __END__
« Attributes/Trait/Role.pm ↑ Summary Attributes/Trait/Role/Application/ToClass.pm »