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 = '0.3.0_2'; |
5
|
|
|
|
|
|
|
} |
6
|
4
|
|
|
4
|
|
117643
|
use Any::Moose (); |
|
4
|
|
|
|
|
202200
|
|
|
4
|
|
|
|
|
138
|
|
7
|
4
|
|
|
4
|
|
51
|
use Any::Moose '::Exporter'; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
27
|
|
8
|
|
|
|
|
|
|
|
9
|
4
|
|
|
4
|
|
1655
|
use constant ROLE_CLASS => 'MooseX::Event::Role'; |
|
4
|
|
|
|
|
17
|
|
|
4
|
|
|
|
|
2163
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
{ |
12
|
|
|
|
|
|
|
my($import,$unimport,$init_meta) = any_moose('::Exporter')->build_import_methods( |
13
|
|
|
|
|
|
|
as_is => [qw( has_event has_events )], |
14
|
|
|
|
|
|
|
also => any_moose(), |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub import { |
18
|
4
|
|
|
4
|
|
30
|
my $class = shift; |
19
|
|
|
|
|
|
|
|
20
|
4
|
|
|
|
|
11
|
my $with_args = {}; |
21
|
|
|
|
|
|
|
|
22
|
4
|
|
|
|
|
9
|
my @args; |
23
|
4
|
|
|
|
|
19
|
while (local $_ = shift @_) { |
24
|
1
|
50
|
|
|
|
4
|
if ( $_ eq '-alias' ) { |
|
|
0
|
|
|
|
|
|
25
|
1
|
|
|
|
|
4
|
$with_args->{'-alias'} = shift; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
elsif ( $_ eq '-excludes' ) { |
28
|
0
|
|
|
|
|
0
|
$with_args->{'-excludes'} = shift; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
else { |
31
|
0
|
|
|
|
|
0
|
push @args, $_; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
4
|
|
|
|
|
11
|
my $caller = caller(); |
36
|
4
|
|
|
|
|
37
|
$class->$import( { into => $caller }, @args ); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# I would expect that 'base_class_roles' in setup_import_methods would |
39
|
|
|
|
|
|
|
# do the below, but no, it doesn't. |
40
|
4
|
50
|
|
|
|
1490
|
if ( ! any_moose('::Util')->can('does_role')->( $caller, ROLE_CLASS ) ) { |
41
|
4
|
|
|
|
|
651
|
eval q{ require }.ROLE_CLASS; |
42
|
4
|
|
|
|
|
51
|
ROLE_CLASS->meta->apply( $caller->meta, %{$with_args} ); |
|
4
|
|
|
|
|
143
|
|
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
4
|
|
|
4
|
|
33528
|
sub unimport { goto $unimport; } |
47
|
|
|
|
|
|
|
*init_meta = $init_meta if defined $init_meta; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
my %meta; |
53
|
|
|
|
|
|
|
sub has_event { |
54
|
4
|
|
|
4
|
1
|
1111
|
my $class = caller(); |
55
|
4
|
|
|
|
|
17
|
for (@_) { |
56
|
|
|
|
|
|
|
$class->meta->add_attribute( |
57
|
|
|
|
|
|
|
"event:$_", |
58
|
|
|
|
|
|
|
init_arg => undef, |
59
|
|
|
|
|
|
|
is => 'ro', |
60
|
|
|
|
|
|
|
lazy => 1, |
61
|
|
|
|
|
|
|
default => sub { |
62
|
0
|
|
|
0
|
|
|
require MooseX::Event::Meta; |
63
|
0
|
|
|
|
|
|
MooseX::Event::Meta->new(object=>shift); |
64
|
|
|
|
|
|
|
}, |
65
|
4
|
|
|
|
|
28
|
); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
4
|
|
|
4
|
|
93
|
BEGIN { *has_events = \&has_event } |
70
|
|
|
|
|
|
|
|
71
|
4
|
|
|
4
|
|
23
|
no Any::Moose '::Exporter'; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
25
|
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
1; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
__END__ |