line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Devel::Events::Generator::ClassPublisher; |
4
|
1
|
|
|
1
|
|
37700
|
use Moose; |
|
1
|
|
|
|
|
580108
|
|
|
1
|
|
|
|
|
10
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
with qw/Devel::Events::Generator/; |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
7548
|
use Class::Publisher; |
|
1
|
|
|
|
|
4394
|
|
|
1
|
|
|
|
|
154
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = "0.01"; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub subscribe { |
13
|
0
|
|
|
0
|
|
|
my ( $self, $publisher, $event ) = @_; |
14
|
|
|
|
|
|
|
|
15
|
0
|
0
|
|
|
|
|
$event = '*' unless defined $event; |
16
|
|
|
|
|
|
|
|
17
|
0
|
|
|
|
|
|
$publisher->add_subscriber( $event, $self ); |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub unsubscribe { |
21
|
0
|
|
|
0
|
|
|
my ( $self, $publisher, $event ) = @_; |
22
|
|
|
|
|
|
|
|
23
|
0
|
|
|
|
|
|
$publisher->delete_subscriber($event, $self); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub update { |
27
|
0
|
|
|
0
|
|
|
my ( $self, $publisher, $type, @data ) = @_; |
28
|
0
|
|
|
|
|
|
$self->send_event( $type, publisher => $publisher, @data ); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
__PACKAGE__; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
__END__ |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=pod |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 NAME |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
Devel::Events::Generator::ClassPublisher - Relay events from |
40
|
|
|
|
|
|
|
L<Class::Publisher> |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 SYNOPSIS |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
use Devel::Events::Generator::ClassPublisher; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
my $gen = Devel::Events::Generator::ClassPublisher->new( |
47
|
|
|
|
|
|
|
handler => $handler, |
48
|
|
|
|
|
|
|
); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
$gen->subscribe( $publisher, $event ); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 DESCRIPTION |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
This event generator can glue events from L<Class::Publisher> into the |
55
|
|
|
|
|
|
|
L<Devel::Events> framework. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
This is useful if you wish to place certain events like |
58
|
|
|
|
|
|
|
L<Devel::Events::Objects>'s ones in a certain context by later analyzing the in |
59
|
|
|
|
|
|
|
memory log. |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 METHODS |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=over 4 |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=item subscribe $publisher, [ $event ] |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=item unsubscribe $publisher, [ $event ] |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
These convenience methods are provided if you prefer calling |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
$gen->subscribe($publisher, $event); |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
over |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
$publisher->add_subscriber($event, $gen); |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
If C<$event> is omitted then all events are assumed. |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=item update $publisher, $event, @args |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Called by L<Class::Publisher/notify_subscribers>. Will raise an event with the |
82
|
|
|
|
|
|
|
value: |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
$event, publisher => $publisher, @args |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
A custom filter right after this generator to munge C<@args> into a key value |
87
|
|
|
|
|
|
|
pair list is reccomended if your events are not structured that way to begin |
88
|
|
|
|
|
|
|
with. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=back |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 SEE ALSO |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
L<Devel::Events>, L<Class::Publisher> |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 AUTHOR |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Yuval Kogman <nothingmuch@woobling.org> |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Copyright (c) 2007 Yuval Kogman. All rights reserved |
103
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
104
|
|
|
|
|
|
|
under the terms of the MIT license or the same terms as Perl itself. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=cut |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
|