Attributes/Trait/Role/Application/ToClass.pm

filter: Statementstmt 100% 20 / 20 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 100% 27 / 27 CC 2 SCAR 2.9
CC
2
Cov
100%
__ANON__
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.3
« Attributes/Trait/Role/Application/ToRole.pm ↑ Summary Attributes/Trait/Attribute/Native/Trait.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::ToClass;
11 9 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
12 9 $MooseX::TrackDirty::Attributes::Trait::Role::Application::ToClass::AUTHORITY = 'cpan:RSRCHBOY';
13 }
14 9 $MooseX::TrackDirty::Attributes::Trait::Role::Application::ToClass::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 MooseX::TrackDirty::Attributes::Util ':all';
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 # debug...
22 #use Smart::Comments;
23  
24  
25 7 ▶after apply => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
26 7 my ($self, $role, $target) = @_;
27  
28 ### in Application--ToClass...
29  
30 ### role: $role->name
31 ### target: $target->name
32  
33 ### applying metaroles to: $target->name
34 7 Moose::Util::MetaRole::apply_metaroles(
35 for => $target,
36 class_metaroles => {
37 class => [ trait_for 'Class' ],
38 },
39 );
40  
41 7 my @roles = map { $_->name } $target->calculate_all_roles;
42 ### @roles
43  
44 ### check to see if our target now does the native trait...
45 return
46 7 ▶ unless $target->does_role('Moose::Meta::Attribute::Native::Trait');
Branch: 1 branch
BranchTrueFalseTotal
unless $target->does_role("Moose::Meta::Attribute::Native::Trait") 4 3 7
47  
48 ### applying to: $target->name
49 3 TrackDirtyNativeTrait->meta->apply($target);
50 3 return;
51 9 };
52  
53 9 !!42;
54  
55 __END__
« Attributes/Trait/Role/Application/ToRole.pm ↑ Summary Attributes/Trait/Attribute/Native/Trait.pm »