Eve/Event.pm

filter: Statementstmt 50.0% 10 / 20 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 60.0% 3 / 5 Podpod 100% 2 / 2 totaltotal 55.5% 15 / 27 CC 2 SCAR 10.4
CC
2
Cov
50%
trigger
6.0
init
2.0
BEGIN
1.0
CRAP 2.8
« Eve/HttpRequest/Psgi.pm ↑ Summary Eve/Support.pm »
1 package Eve::Event;
2  
3 9 ▶use parent qw(Eve::Class);
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 9 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 =head1 NAME
9  
10 B<Eve::Event> - a base class for all event classes.
11  
12 =head1 SYNOPSIS
13  
14 package Eve::Event::Foo;
15  
16 use parent qw(Eve::Event);
17  
18 1;
19  
20 my $event = Eve::Event::Foo->new(event_map => $event_map)
21 ->trigger();
22  
23 =head1 DESCRIPTION
24  
25 B<Eve::Event> is an abstract class that must be inherited
26 by event classes. This will enable them to be triggered and have
27 handlers bound to them.
28  
29 =head3 Constructor arguments:
30  
31 =over 4
32  
33 =item C<event_map>
34  
35 an event map the event will interact with.
36  
37 =back
38  
39 =head1 METHODS
40  
41 =head2 B<init()>
42  
43 =cut
44  
45 0 ▶sub init {
Subroutine init: not called CC=1 SCAR=6.9
Pod documented
46 0 my ($self, %arg_hash) = @_;
47 0 Eve::Support::arguments(\%arg_hash, my $event_map);
48  
49 0 $self->{'_event_map'} = $event_map;
50  
51 0 return;
52 }
53  
54 =head2 B<trigger()>
55  
56 The C<trigger()> method is used to start processing the event by all
57 handlers that are bound to it and its ancestors.
58  
59 =cut
60  
61 0 ▶sub trigger {
Subroutine trigger: not called CC=2 SCAR=17.9
Pod documented
62 0 my $self = shift;
63  
64 0 my $handler_list = $self->_event_map->get_handler_list(event => $self);
65 0 for my $handler (@{$handler_list}) {
66 0 $handler->handle(event => $self);
67 }
68  
69 0 return;
70 }
71  
72 =head1 SEE ALSO
73  
74 =over 4
75  
76 =item L<Eve::Class>
77  
78 =item L<Eve::EventMap>
79  
80 =back
81  
82 =head1 LICENSE AND COPYRIGHT
83  
84 Copyright 2012 Igor Zinovyev.
85  
86 This program is free software; you can redistribute it and/or modify it
87 under the terms of either: the GNU General Public License as published
88 by the Free Software Foundation; or the Artistic License.
89  
90 See http://dev.perl.org/licenses/ for more information.
91  
92  
93 =head1 AUTHOR
94  
95 =over 4
96  
97 =item L<Sergey Konoplev|mailto:gray.ru@gmail.com>
98  
99 =back
100  
101 =cut
102  
103 9 1;
« Eve/HttpRequest/Psgi.pm ↑ Summary Eve/Support.pm »