blib/lib/MooX/POE.pm

filter: Statementstmt 71.8% 46 / 64 Branchbran 75.0% 6 / 8 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 59.0% 13 / 22 Podpod 0.0% 0 / 16 totaltotal 58.4% 66 / 113 CC 8 SCAR 7.7
CC
8
Cov
72%
BUILD
4.1
STARTALL
3.0
STOPALL
3.0
CRAP 2.2
↑ Summary
1 package MooX::POE;
2 4 our $AUTHORITY = 'cpan:GETTY';
3 # ABSTRACT: POE::Session combined with Moo (or Moose, if you want)
4 4 $MooX::POE::VERSION = '0.002';
5 4 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 ▶use Package::Stash;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 4 ▶use POE qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
9 Session
10 4 );
11  
12 22 ▶sub BUILD {
Subroutine BUILD: called CC=4 SCAR=14.1
Pod undocumented
13 22 my $self = shift;
14 22 my $ps = Package::Stash->new(ref $self);
15 my $session = POE::Session->create(
16 inline_states => {
17 22 ▶ _start => sub { POE::Kernel->yield('STARTALL', \$_[5] ) },
Subroutine __ANON__: called CC=1 SCAR=0.0
18 map {
19 34 my $func = $_;
20 34 my ( $event ) = $func =~ /^on_(.*)$/;
21 103 ▶ $event, sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
22 103 my ( @args ) = @_[ ARG0..$#_ ];
23 103 $self->$func(@args);
24 34 };
25 1075 ▶ } grep { /^on_/ } $ps->list_all_symbols('CODE'),
Branch: 2 branches
BranchTrueFalseTotal
$self->can('CHILD') ? : 0 22 22
$self->can('PARENT') ? : 0 22 22
Condition50%1/2
$self->{"heap"} ||= {}
l!l
022
MC/DC0%0/1
$self->{"heap"} ||= {}
$self->{"heap"}
Truth table50%1/2
A
A= $self->{"heap"}
Aresult
11
00
26 },
27 object_states => [
28 $self => {
29 STARTALL => 'STARTALL',
30 _stop => 'STOPALL',
31 $self->can('CHILD') ? ( _child => 'CHILD' ) : (),
32 $self->can('PARENT') ? ( _parent => 'PARENT' ) : (),
33 _call_kernel_with_my_session => '_call_kernel_with_my_session',
34 },
35 ],
36 args => [ $self ],
37 22 heap => ( $self->{heap} ||= {} ),
38 );
39 22 $self->{session_id} = $session->ID;
40 }
41  
42 103 ▶sub get_session_id {
Subroutine get_session_id: called CC=1 SCAR=0.0
Pod undocumented
43 103 my ( $self ) = @_;
44 103 return $self->{session_id};
45 }
46  
47 100 ▶sub yield { my $self = shift; POE::Kernel->post( $self->get_session_id, @_ ) }
Subroutine yield: called CC=1 SCAR=0.0
Pod undocumented
48 3 ▶sub call { my $self = shift; POE::Kernel->call( $self->get_session_id, @_ ) }
Subroutine call: called CC=1 SCAR=0.0
Pod undocumented
49  
50 3 ▶sub _call_kernel_with_my_session {
Subroutine _call_kernel_with_my_session: called CC=1 SCAR=0.0
51 3 my ( $self, $function, @args ) = @_[ OBJECT, ARG0..$#_ ];
52 3 POE::Kernel->$function( @args );
53 }
54
55 3 ▶sub delay { my $self = shift; $self->call( _call_kernel_with_my_session => 'delay' => @_ ) }
Subroutine delay: called CC=1 SCAR=0.0
Pod undocumented
56 0 ▶sub alarm { my $self = shift; $self->call( _call_kernel_with_my_session => 'alarm', @_ ) }
Subroutine alarm: not called CC=1 SCAR=6.9
Pod undocumented
57 0 ▶sub alarm_add { my $self = shift; $self->call( _call_kernel_with_my_session => 'alarm_add', @_ ) }
Subroutine alarm_add: not called CC=1 SCAR=6.9
Pod undocumented
58 0 ▶sub delay_add { my $self = shift; $self->call( _call_kernel_with_my_session => 'delay_add', @_ ) }
Subroutine delay_add: not called CC=1 SCAR=6.9
Pod undocumented
59 0 ▶sub alarm_set { my $self = shift; $self->call( _call_kernel_with_my_session => 'alarm_set', @_ ) }
Subroutine alarm_set: not called CC=1 SCAR=6.9
Pod undocumented
60 0 ▶sub alarm_adjust { my $self = shift; $self->call( _call_kernel_with_my_session => 'alarm_adjust', @_ ) }
Subroutine alarm_adjust: not called CC=1 SCAR=6.9
Pod undocumented
61 0 ▶sub alarm_remove { my $self = shift; $self->call( _call_kernel_with_my_session => 'alarm_remove', @_ ) }
Subroutine alarm_remove: not called CC=1 SCAR=6.9
Pod undocumented
62 0 ▶sub alarm_remove_all { my $self = shift; $self->call( _call_kernel_with_my_session => 'alarm_remove_all', @_ ) }
Subroutine alarm_remove_all: not called CC=1 SCAR=6.9
Pod undocumented
63 0 ▶sub delay_set { my $self = shift; $self->call( _call_kernel_with_my_session => 'delay_set', @_ ) }
Subroutine delay_set: not called CC=1 SCAR=6.9
Pod undocumented
64 0 ▶sub delay_adjust { my $self = shift; $self->call( _call_kernel_with_my_session => 'delay_adjust', @_ ) }
Subroutine delay_adjust: not called CC=1 SCAR=6.9
Pod undocumented
65
66 22 ▶sub STARTALL {
Subroutine STARTALL: called CC=3 SCAR=11.0
Pod undocumented
67 22 my ( $self, @params ) = @_;
68 22 $params[4] = pop @params;
69 22 my @isa = @{mro::get_linear_isa(ref $self)};
70 22 for my $caller (@isa) {
71 44 my $can = $caller->can('START');
72 44 ▶ $can->( $self, @params ) if $can;
Branch: 1 branch
BranchTrueFalseTotal
if $can 21 23 44
73 }
74 }
75
76 22 ▶sub STOPALL {
Subroutine STOPALL: called CC=3 SCAR=11.0
Pod undocumented
77 22 my ( $self, $params ) = @_;
78 22 my @isa = @{mro::get_linear_isa(ref $self)};
79 22 for my $caller (@isa) {
80 44 my $can = $caller->can('STOP');
81 44 ▶ $can->( $self, $params ) if $can;
Branch: 1 branch
BranchTrueFalseTotal
if $can 20 24 44
82 }
83 }
84  
85 4 1;
86  
87 __END__
↑ Summary