line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Devel::Events::Filter::Callback; |
4
|
1
|
|
|
1
|
|
41140
|
use Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
with qw/Devel::Events::Filter/; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
has callback => ( |
9
|
|
|
|
|
|
|
isa => "CodeRef", |
10
|
|
|
|
|
|
|
is => "rw", |
11
|
|
|
|
|
|
|
required => 1, |
12
|
|
|
|
|
|
|
); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub filter_event { |
15
|
|
|
|
|
|
|
my ( $self, @event ) = @_; |
16
|
|
|
|
|
|
|
$self->callback->(@event); |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
__PACKAGE__; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
__END__ |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=pod |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 NAME |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
Devel::Events::Filter::Callback - Callback based L<Devel::Events::Filter> |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 SYNOPSIS |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
use Devel::Events::Filter::Callback; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
Devel::Events::Filter::Callback->new( |
34
|
|
|
|
|
|
|
callback => sub { |
35
|
|
|
|
|
|
|
my ( @event ) = @_; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
return if bad_event(@event); # drop it |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
return map { filter($_) } @event; # change it |
40
|
|
|
|
|
|
|
}, |
41
|
|
|
|
|
|
|
handler => $handler, |
42
|
|
|
|
|
|
|
); |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 DESCRIPTION |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Duh. |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=over 4 |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=item handler |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
L<Devel::Events::Handler> |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=item callback |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
a code ref |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=back |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 METHODS |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=over 4 |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=item filter_event |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Delegates to C<callback> |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=back |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=cut |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|