Events/Dispatcher.pm

filter: Statementstmt 50.0% 13 / 26 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 30.0% 3 / 10 Podpod 100% 3 / 3 totaltotal 48.7% 19 / 39 CC 2 SCAR 8.3
CC
2
Cov
50%
new
6.0
__ANON__
2.0
__ANON__
2.0
CRAP 2.3
« Events/AsyncListener.pm ↑ Summary Events/Listeners/Say.pm »
1 package Mojo::Events::Dispatcher;
2 2 ▶use Mojo::Base 'Mojo::EventEmitter';
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 2 ▶use Mojo::Events::Listeners;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use Mojo::Server;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 0 ▶has app => sub { Mojo::Server->new->build_app('Mojo::HelloWorld') }, weak => 1;
Subroutine __ANON__: not called CC=1 SCAR=1.2
8 0 ▶has listeners => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
9 0 my $self = shift;
10  
11 0 return Mojo::Events::Listeners->new(app => $self->app, namespaces => $self->namespaces);
12 2 };
13 0 ▶has namespaces => sub { [] };
Subroutine __ANON__: not called CC=1 SCAR=1.2
14  
15 =head2 new
16  
17 Initialize dispatcher and startup listeners
18  
19 =cut
20  
21 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
Pod documented
22 0 my $self = shift->SUPER::new(@_);
23  
24 0 for my $listener (@{ $self->listeners->registered }) {
25 0 ▶ $self->on($listener->event => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
26 0 my $self = shift;
27
28 0 return $listener->handle(@_);
29 0 });
30 }
31  
32 0 return $self;
33 }
34  
35 =head2 register
36  
37 Proxy for listeners register
38  
39 =cut
40  
41 0 ▶sub register {
Subroutine register: not called CC=1 SCAR=6.9
Pod documented
42 0 return shift->listeners->register(@_);
43 }
44  
45 =head2 dispatch
46  
47 Dispatch event
48  
49 =cut
50  
51 0 ▶sub dispatch {
Subroutine dispatch: not called CC=1 SCAR=6.9
Pod documented
52 0 return shift->emit(@_);
53 }
54  
55 2 1;
« Events/AsyncListener.pm ↑ Summary Events/Listeners/Say.pm »