blib/lib/MooseX/WhatTheTrig.pm

filter: Statementstmt 96.8% 92 / 95 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 94.7% 18 / 19 Podpod n/a totaltotal 95.6% 111 / 116 CC 2 SCAR 1.4
CC
2
Cov
96%
__ANON__
2.0
__ANON__
2.0
BEGIN
1.0
CRAP 1.2
↑ Summary
1 1 ▶use 5.008008;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 ▶use Moose ();
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Moose::Exporter ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 package MooseX::WhatTheTrig;
9  
10 1 our $AUTHORITY = 'cpan:TOBYINK';
11 1 our $VERSION = '0.001';
12  
13 {
14 package MooseX::WhatTheTrig::Trait::Attribute;
15 1 our $AUTHORITY = 'cpan:TOBYINK';
16 1 our $VERSION = '0.001';
17 1 ▶ use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶ use Scope::Guard qw(guard);
Subroutine BEGIN: called CC=1 SCAR=0.0
19
20 after _process_trigger_option => sub
21 4 ▶ {
Subroutine __ANON__: called CC=2 SCAR=6.9
22 4 my $class = shift;
23 4 my ($name, $opts) = @_;
24 4 ▶ return unless exists $opts->{trigger};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $opts->{"trigger"} 0 4 4
25
26 4 my $orig = delete $opts->{trigger};
27 $opts->{trigger} = sub
28 16 ▶ {
Subroutine __ANON__: called CC=1 SCAR=0.0
29 16 my $self = shift;
30 16 my $meta = Moose::Util::find_meta($self);
31 16 my $restore = $meta->triggered_attribute;
32 16 ▶ my $guard = guard { $meta->_set_triggered_attribute($restore) };
Subroutine __ANON__: called CC=1 SCAR=0.0
33 16 $meta->_set_triggered_attribute($name);
34 16 $self->$orig(@_);
35 4 };
36 }
37 1 }
38  
39 {
40 1 package MooseX::WhatTheTrig::Trait::Package;
41 1 our $AUTHORITY = 'cpan:TOBYINK';
42 1 our $VERSION = '0.001';
43 1 ▶ use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
44
45 1 has triggered_attribute => (
46 is => 'ro',
47 writer => '_set_triggered_attribute',
48 );
49 }
50  
51 {
52 1 package MooseX::WhatTheTrig::Trait::Class;
53 1 our $AUTHORITY = 'cpan:TOBYINK';
54 1 our $VERSION = '0.001';
55 1 ▶ use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
56 1 with qw(MooseX::WhatTheTrig::Trait::Package);
57 }
58  
59 {
60 1 package MooseX::WhatTheTrig::Trait::Role;
61 1 our $AUTHORITY = 'cpan:TOBYINK';
62 1 our $VERSION = '0.001';
63 1 ▶ use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
64 1 with qw(MooseX::WhatTheTrig::Trait::Package);
65 }
66  
67 1 my %class_metaroles = (
68 class => ['MooseX::WhatTheTrig::Trait::Class'],
69 );
70  
71 1 my %role_metaroles = (
72 role => ['MooseX::WhatTheTrig::Trait::Role'],
73 application_to_role => ['MooseX::WhatTheTrig::Trait::ApplicationToRole'],
74 application_to_class => ['MooseX::WhatTheTrig::Trait::ApplicationToClass'],
75 );
76  
77 1 'Moose::Exporter'->setup_import_methods(
78 trait_aliases => [ [ 'MooseX::WhatTheTrig::Trait::Attribute' => 'WhatTheTrig' ] ],
79 class_metaroles => \%class_metaroles,
80 role_metaroles => \%role_metaroles,
81 );
82  
83 {
84 package MooseX::WhatTheTrig::Trait::Application;
85 1 our $AUTHORITY = 'cpan:TOBYINK';
86 1 our $VERSION = '0.001';
87 1 ▶ use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
88
89 sub _whatthetrig_metacrap
90 2 ▶ {
Subroutine _whatthetrig_metacrap: called CC=1 SCAR=0.0
91 2 my $self = shift;
92 2 my ($next, $opts, $role, $applied_to) = @_;
93 2 $applied_to = Moose::Util::MetaRole::apply_metaroles(for => $applied_to, %$opts);
94 2 $self->$next($role, $applied_to);
95 }
96 }
97  
98 {
99 1 package MooseX::WhatTheTrig::Trait::ApplicationToClass;
100 1 our $AUTHORITY = 'cpan:TOBYINK';
101 1 our $VERSION = '0.001';
102 1 ▶ use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
103 1 with qw(MooseX::WhatTheTrig::Trait::Application);
104
105 around apply => sub
106 2 ▶ {
Subroutine __ANON__: called CC=1 SCAR=0.0
107 2 my $next = shift;
108 2 my $self = shift;
109 2 $self->_whatthetrig_metacrap($next, { class_metaroles => \%class_metaroles }, @_);
110 1 };
111 }
112  
113 {
114 1 package MooseX::WhatTheTrig::Trait::ApplicationToRole;
115 1 our $AUTHORITY = 'cpan:TOBYINK';
116 1 our $VERSION = '0.001';
117 1 ▶ use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
118 1 with qw(MooseX::WhatTheTrig::Trait::Application);
119
120 around apply => sub
121 0 ▶ {
Subroutine __ANON__: not called CC=1 SCAR=6.9
122 0 my $next = shift;
123 0 my $self = shift;
124 0 $self->_whatthetrig_metacrap($next, { role_metaroles => \%role_metaroles }, @_);
125 1 };
126 }
127  
128 1 1;
129  
130 __END__
↑ Summary