File Coverage

blib/lib/MouseX/POE/Meta/Trait/Object.pm
Criterion Covered Total %
statement 38 57 66.6
branch n/a
condition 5 6 83.3
subroutine 16 26 61.5
pod 19 20 95.0
total 78 109 71.5


line stmt bran cond sub pod time code
1             package MouseX::POE::Meta::Trait::Object;
2             $MouseX::POE::Meta::Trait::Object::VERSION = '0.216';
3             # ABSTRACT: The base class role for MouseX::POE
4              
5 11     11   6752 use Mouse::Role;
  11         19  
  11         82  
6 11     11   2293 use POE::Session;
  11         19  
  11         82  
7 11     11   1070 use Mouse::Util;
  11         16  
  11         81  
8              
9             sub BUILD {
10 47     47 0 19330 my $self = shift;
11              
12             my $session = POE::Session->create(
13             inline_states =>
14 47     47   9988 { _start => sub { POE::Kernel->yield('STARTALL', \$_[5] ) }, },
15 47   50     352 object_states => [
16             $self => {
17             $self->meta->get_all_events,
18             STARTALL => 'STARTALL',
19             _stop => 'STOPALL',
20             _child => 'CHILD',
21             _parent => 'PARENT',
22             _call_kernel_with_my_session => '_call_kernel_with_my_session',
23             },
24             ],
25             args => [$self],
26             heap => ( $self->{heap} ||= {} ),
27             );
28 47         17540 $self->{session_id} = $session->ID;
29             }
30              
31             sub get_session_id {
32 83     83 1 87 my ($self) = @_;
33 83         297 return $self->{session_id};
34             #return $self->meta->get_meta_instance->get_session_id($self);
35             }
36              
37 80     80 1 28513 sub yield { my $self = shift; POE::Kernel->post( $self->get_session_id, @_ ) }
  80         149  
38              
39 3     3 1 2 sub call { my $self = shift; POE::Kernel->call( $self->get_session_id, @_ ) }
  3         11  
40              
41             sub _call_kernel_with_my_session {
42 3     3   110 my ( $self, $function, @args ) = @_[ OBJECT, ARG0..$#_ ];
43 3         11 POE::Kernel->$function( @args );
44             }
45              
46 3     3 1 1000935 sub delay { my $self = shift; $self->call( _call_kernel_with_my_session => 'delay' => @_ ) }
  3         11  
47 0     0 1 0 sub alarm { my $self = shift; $self->call( _call_kernel_with_my_session => 'alarm', @_ ) }
  0         0  
48 0     0 1 0 sub alarm_add { my $self = shift; $self->call( _call_kernel_with_my_session => 'alarm_add', @_ ) }
  0         0  
49 0     0 1 0 sub delay_add { my $self = shift; $self->call( _call_kernel_with_my_session => 'delay_add', @_ ) }
  0         0  
50 0     0 1 0 sub alarm_set { my $self = shift; $self->call( _call_kernel_with_my_session => 'alarm_set', @_ ) }
  0         0  
51 0     0 1 0 sub alarm_adjust { my $self = shift; $self->call( _call_kernel_with_my_session => 'alarm_adjust', @_ ) }
  0         0  
52 0     0 1 0 sub alarm_remove { my $self = shift; $self->call( _call_kernel_with_my_session => 'alarm_remove', @_ ) }
  0         0  
53 0     0 1 0 sub alarm_remove_all { my $self = shift; $self->call( _call_kernel_with_my_session => 'alarm_remove_all', @_ ) }
  0         0  
54 0     0 1 0 sub delay_set { my $self = shift; $self->call( _call_kernel_with_my_session => 'delay_set', @_ ) }
  0         0  
55 0     0 1 0 sub delay_adjust { my $self = shift; $self->call( _call_kernel_with_my_session => 'delay_adjust', @_ ) }
  0         0  
56              
57             sub STARTALL {
58 47     47 1 19331 my ( $self, @params ) = @_;
59 47         83 $params[4] = pop @params;
60 47         161 for my $class (reverse $self->meta->linearized_isa) {
61 145   100     3096 my $start = Mouse::Util::get_code_ref($class, 'START')
62             || next;
63 97         278 $start->( $self, @params );
64             }
65             }
66              
67             sub STOPALL {
68 76     76 1 1049040 my ( $self, $params ) = @_;
69 76         211 for my $class (reverse $self->meta->linearized_isa) {
70 232   100     1496 my $start = Mouse::Util::get_code_ref($class, 'STOP')
71             || next;
72 145         215 $start->( $self, $params );
73             }
74             }
75              
76 47     47 1 51 sub START { }
77 76     76 1 85 sub STOP { }
78 2     2 1 135 sub CHILD { }
79 0     0 1   sub PARENT { }
80              
81             # __PACKAGE__->meta->add_method( _stop => sub { POE::Kernel->call('STOP') } );
82              
83              
84 11     11   5909 no Mouse::Role;
  11         18  
  11         52  
85              
86             1;
87              
88             __END__