File Coverage

blib/lib/MouseX/POE/Meta/Trait.pm
Criterion Covered Total %
statement 13 16 81.2
branch 2 4 50.0
condition n/a
subroutine 5 5 100.0
pod 0 3 0.0
total 20 28 71.4


line stmt bran cond sub pod time code
1             package MouseX::POE::Meta::Trait;
2             $MouseX::POE::Meta::Trait::VERSION = '0.216';
3             # ABSTRACT: There be dragons here.
4 11     11   4380 use Mouse::Role;
  11         15  
  11         49  
5              
6 11     11   5049 use MouseX::POE::Meta::Method::State;
  11         21  
  11         1538  
7              
8             has events => (
9             reader => 'get_events',
10             traits => ['Array'],
11             isa => 'ArrayRef',
12             auto_deref => 1,
13             lazy_build => 1,
14             builder => 'default_events',
15             handles => { 'add_event' => ['push'] },
16             );
17              
18             sub default_events {
19 13     13 0 29 return [];
20             }
21              
22             sub get_state_method_name {
23 107     107 0 103 my ( $self, $name ) = @_;
24 107 50       162 return $name if $self->has_method($name);
25 0         0 return undef;
26             }
27              
28             sub add_state_method {
29 11     11 0 17 my ( $self, $name, $method ) = @_;
30 11 50       52 if ( $self->has_method($name) ) {
31 0         0 my $full_name = $self->get_method($name)->fully_qualified_name;
32 0         0 confess "Cannot add a state method ($name) if a local method ($full_name) is already present";
33             }
34              
35 11         182 $self->add_event($name);
36 11         152 $self->add_method( $name => $method );
37             }
38              
39             1;
40              
41             __END__