line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MooseX::Async::Meta::Trait; |
2
|
1
|
|
|
1
|
|
1799
|
use Moose::Role; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
use MooseX::Async::Meta::Method::State; |
5
|
|
|
|
|
|
|
use MooseX::AttributeHelpers; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
has events => ( |
8
|
|
|
|
|
|
|
reader => 'get_events', |
9
|
|
|
|
|
|
|
metaclass => 'Collection::Array', |
10
|
|
|
|
|
|
|
isa => 'ArrayRef', |
11
|
|
|
|
|
|
|
auto_deref => 1, |
12
|
|
|
|
|
|
|
lazy_build => 1, |
13
|
|
|
|
|
|
|
builder => 'default_events', |
14
|
|
|
|
|
|
|
provides => { push => 'add_event', } |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub default_events { |
18
|
|
|
|
|
|
|
return []; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub get_state_method_name { |
22
|
|
|
|
|
|
|
my ( $self, $name ) = @_; |
23
|
|
|
|
|
|
|
return $name if $self->has_method($name); |
24
|
|
|
|
|
|
|
return undef; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub add_state_method { |
28
|
|
|
|
|
|
|
my ( $self, $name, $method ) = @_; |
29
|
|
|
|
|
|
|
if ( $self->has_method($name) ) { |
30
|
|
|
|
|
|
|
my $full_name = $self->get_method($name)->fully_qualified_name; |
31
|
|
|
|
|
|
|
confess |
32
|
|
|
|
|
|
|
"Cannot add a state method ($name) if a local method ($full_name) is already present"; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
$self->add_event($name); |
36
|
|
|
|
|
|
|
$self->add_method( $name => $method ); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
after add_role => sub { |
40
|
|
|
|
|
|
|
my ( $self, $role ) = @_; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
if ( $role->isa("MooseX::Async::Meta::Role") ) { |
43
|
|
|
|
|
|
|
$self->add_event($role->get_events); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
}; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |