line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Devel::Events::Generator; |
4
|
1
|
|
|
1
|
|
4524
|
use Moose::Role; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
has handler => ( |
7
|
|
|
|
|
|
|
# does => "Devel::Events::Handler", # we like duck typing |
8
|
|
|
|
|
|
|
isa => "Object", |
9
|
|
|
|
|
|
|
is => "rw", |
10
|
|
|
|
|
|
|
required => 1, |
11
|
|
|
|
|
|
|
); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub send_event { |
14
|
|
|
|
|
|
|
my ( $self, $type, @data ) = @_; |
15
|
|
|
|
|
|
|
$self->handler->new_event( $type, generator => $self, @data ); |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
__PACKAGE__; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
__END__ |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=pod |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 NAME |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
Devel::Events::Generator - An optional base role for event generators. |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 SYNOPSIS |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
package MyGen; |
31
|
|
|
|
|
|
|
use Moose; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
with qw/Devel::Events::Generator/; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub whatever { |
36
|
|
|
|
|
|
|
my ( $self, @args ) = @_; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# ... |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
$self->send_event( @event ); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 DESCRIPTION |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
This convenience role provides a basic C<send_event> method, useful for |
46
|
|
|
|
|
|
|
implementing generators. |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=over 4 |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=item handler |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Accepts any object. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Required. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=back |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 METHODS |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=over 4 |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=item send_event @event |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Delegates to C<handler>, calling the method C<new_event> on it. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
The field C<generator> with the value of the generator object will be |
69
|
|
|
|
|
|
|
prepended. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=back |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=cut |
74
|
|
|
|
|
|
|
|