line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: A Node style event Role for Moose |
2
|
|
|
|
|
|
|
package MooseX::Event; |
3
|
|
|
|
|
|
|
{ |
4
|
|
|
|
|
|
|
$MooseX::Event::VERSION = 'v0.2.0'; |
5
|
|
|
|
|
|
|
} |
6
|
3
|
|
|
3
|
|
55010
|
use Any::Moose (); |
|
3
|
|
|
|
|
126839
|
|
|
3
|
|
|
|
|
81
|
|
7
|
3
|
|
|
3
|
|
40
|
use Any::Moose '::Exporter'; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
52
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
{ |
10
|
|
|
|
|
|
|
my($import,$unimport,$init_meta) = any_moose('::Exporter')->build_import_methods( |
11
|
|
|
|
|
|
|
as_is => [qw( has_event has_events )], |
12
|
|
|
|
|
|
|
also => any_moose(), |
13
|
|
|
|
|
|
|
); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub import { |
16
|
3
|
|
|
3
|
|
24
|
my $class = shift; |
17
|
|
|
|
|
|
|
|
18
|
3
|
|
|
|
|
9
|
my $with_args = {}; |
19
|
|
|
|
|
|
|
|
20
|
3
|
|
|
|
|
6
|
my @args; |
21
|
3
|
|
|
|
|
14
|
while (local $_ = shift @_) { |
22
|
1
|
50
|
|
|
|
6
|
if ( $_ eq '-alias' ) { |
|
|
0
|
|
|
|
|
|
23
|
1
|
|
|
|
|
4
|
$with_args->{'-alias'} = shift; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
elsif ( $_ eq '-excludes' ) { |
26
|
0
|
|
|
|
|
0
|
$with_args->{'-excludes'} = shift; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
else { |
29
|
0
|
|
|
|
|
0
|
push @args, $_; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
3
|
|
|
|
|
8
|
my $caller = caller(); |
34
|
3
|
|
|
|
|
18
|
$class->$import( { into => $caller }, @args ); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# I would expect that 'base_class_roles' in setup_import_methods would |
37
|
|
|
|
|
|
|
# do the below, but no, it doesn't. |
38
|
3
|
50
|
|
|
|
1230
|
if ( ! any_moose('::Util')->can('does_role')->( $caller, 'MooseX::Event::Role' ) ) { |
39
|
3
|
|
|
|
|
2522
|
require MooseX::Event::Role; |
40
|
3
|
|
|
|
|
17
|
MooseX::Event::Role->meta->apply( $caller->meta, %{$with_args} ); |
|
3
|
|
|
|
|
81
|
|
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
3
|
|
|
3
|
|
20237
|
sub unimport { goto $unimport; } |
45
|
|
|
|
|
|
|
*init_meta = $init_meta if defined $init_meta; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
our @listener_wrappers; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub add_listener_wrapper { |
53
|
0
|
|
|
0
|
1
|
0
|
my( $wrapper ) = @_[1..$#_]; |
54
|
0
|
|
|
|
|
0
|
push @listener_wrappers, $wrapper; |
55
|
0
|
|
|
|
|
0
|
return $wrapper; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub remove_listener_wrapper { |
60
|
0
|
|
|
0
|
1
|
0
|
my( $wrapper ) = @_[1..$#_]; |
61
|
0
|
|
|
|
|
0
|
@listener_wrappers = grep { $_ != $wrapper } @listener_wrappers; |
|
0
|
|
|
|
|
0
|
|
62
|
0
|
|
|
|
|
0
|
return; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
0
|
|
0
|
my $stub = sub {}; |
69
|
|
|
|
|
|
|
sub has_event { |
70
|
6
|
|
|
6
|
1
|
433
|
my $class = caller(); |
71
|
6
|
|
|
|
|
47
|
$class->meta->add_method( "event:$_" => $stub ) for @_; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
3
|
|
|
3
|
|
2592
|
BEGIN { *has_events = \&has_event } |
75
|
|
|
|
|
|
|
|
76
|
3
|
|
|
3
|
|
24
|
no Any::Moose '::Exporter'; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
13
|
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
1; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
__END__ |