POE/Meta/Trait/Class.pm

filter: Statementstmt 100% 34 / 34 Branchbran 100% 4 / 4 Conditioncond 66.6% 4 / 6 MC/DCmcdc 50.0% 2 / 4 Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 92.7% 51 / 55 CC 5 SCAR 7.0
CC
5
Cov
95%
__ANON__
3.0
get_all_events
2.0
__ANON__
2.0
CRAP 2.0
« POE/Aliased.pm ↑ Summary POE/Meta/Trait/Instance.pm »
1 package MooseX::POE::Meta::Trait::Class;
2 {
3 16 $MooseX::POE::Meta::Trait::Class::VERSION = '0.215';
4 }
5 # ABSTRACT: No achmed inside
6 16 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 16 with qw(MooseX::POE::Meta::Trait);
9  
10 # TODO: subclass events to be a hashref that maps the event to the method
11 # so we can support on_ events
12  
13 20 ▶around default_events => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
14 20 my ( $next, $self ) = @_;
15 20 my $events = $next->($self);
16 20 push @$events, grep { s/^on_(\w+)/$1/; } $self->get_method_list;
17 20 return $events;
18 16 };
19  
20 6 ▶around add_role => sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
21 6 my ( $next, $self, $role ) = @_;
22 6 $next->( $self, $role );
23  
24 6 ▶ if ( $role->meta->can('does_role')
Branch: 1 branch
BranchTrueFalseTotal
if ($role->meta->can("does_role") and $role->meta->does_role("MooseX::POE::Meta::Trait")) 5 1 6
Condition66%2/3
$role->meta->can("does_role") and $role->meta->does_role("MooseX::POE::Meta::Trait")
!ll&&!rl&&r
105
MC/DC50%1/2
$role->meta->can("does_role") and $role->meta->does_role("MooseX::POE::Meta::Trait")
$role->meta->can("does_role") $role->meta->does_role("MooseX::POE::Meta::Trait")
Truth table66%2/3
A and B
A= $role->meta->can("does_role")B= $role->meta->does_role("MooseX::POE::Meta::Trait")
ABresult
0X0
100
111
25 && $role->meta->does_role("MooseX::POE::Meta::Trait") ) {
26 5 $self->add_event( $role->get_events );
27 }
28 16 };
29  
30 125 ▶around get_state_method_name => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
31 125 my ( $next, $self, $name ) = @_;
32 125 ▶ return 'on_' . $name if $self->has_method( 'on_' . $name );
Branch: 1 branch
BranchTrueFalseTotal
if $self->has_method('on_' . $name) 15 110 125
33 110 return $next->( $self, $name );
34 16 };
35  
36 50 ▶sub get_all_events {
Subroutine get_all_events: called CC=2 SCAR=6.9
Pod documented
37 50 my ($self) = @_;
38 50 my $wanted_role = 'MooseX::POE::Meta::Trait';
39  
40 # This horrible grep can be removed once Moose gets more metacircular.
41 # Currently Moose::Meta::Class->meta isn't a MMC. It should be, and it
42 # should also be a Moose::Object so does works on it.
43 my %events
44 = map {
45 54 my $m = $_;
46 54 map { $_ => $m->get_state_method_name($_) } $m->get_events
47 }
48 grep {
49 154 ▶ $_->meta->can('does_role') && $_->meta->does_role($wanted_role)
Condition66%2/3
$_->meta->can('does_role') && $_->meta->does_role($wanted_role)
!ll&&!rl&&r
100054
MC/DC50%1/2
$_->meta->can('does_role') && $_->meta->does_role($wanted_role)
$_->meta->can('does_role') $_->meta->does_role($wanted_role)
Truth table66%2/3
A && B
A= $_->meta->can('does_role')B= $_->meta->does_role($wanted_role)
ABresult
0X0
100
111
50 }
51 50 map { $_->meta } $self->linearized_isa;
52 50 return %events;
53 }
54  
55 16 ▶no Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
56 16 1;
57  
58  
59 =pod
60  
61 =head1 NAME
62  
63 MooseX::POE::Meta::Trait::Class - No achmed inside
64  
65 =head1 VERSION
66  
67 version 0.215
68  
69 =head1 METHODS
70  
71 =head2 get_all_events
72  
73 =head1 METHODS
74  
75 =head1 DEPENDENCIES
76  
77 Moose::Role
78  
79 =head1 AUTHORS
80  
81 =over 4
82  
83 =item *
84  
85 Chris Prather <chris@prather.org>
86  
87 =item *
88  
89 Ash Berlin <ash@cpan.org>
90  
91 =item *
92  
93 Chris Williams <chris@bingosnet.co.uk>
94  
95 =item *
96  
97 Yuval (nothingmuch) Kogman
98  
99 =item *
100  
101 Torsten Raudssus <torsten@raudssus.de> L<http://www.raudssus.de/>
102  
103 =back
104  
105 =head1 COPYRIGHT AND LICENSE
106  
107 This software is copyright (c) 2010 by Chris Prather, Ash Berlin, Chris Williams, Yuval Kogman, Torsten Raudssus.
108  
109 This is free software; you can redistribute it and/or modify it under
110 the same terms as the Perl 5 programming language system itself.
111  
112 =cut
113  
114  
115 __END__
« POE/Aliased.pm ↑ Summary POE/Meta/Trait/Instance.pm »