File Coverage

lib/Devel/ebug/Wx/Plugin/Listener/Base.pm
Criterion Covered Total %
statement 9 24 37.5
branch 0 8 0.0
condition 0 3 0.0
subroutine 3 5 60.0
pod 0 2 0.0
total 12 42 28.5


line stmt bran cond sub pod time code
1             package Devel::ebug::Wx::Plugin::Listener::Base;
2              
3 1     1   6 use strict;
  1         2  
  1         33  
4 1     1   5 use base qw(Class::Accessor::Fast);
  1         2  
  1         67  
5 1     1   5 use Scalar::Util qw(weaken);
  1         1  
  1         252  
6              
7             __PACKAGE__->mk_accessors( qw(_subscribed) );
8              
9             sub add_subscription {
10 0     0 0   my( $self, $source, @args ) = @_;
11              
12 0 0         $self->_subscribed( [] ) unless $self->_subscribed;
13 0           $source->add_subscriber( @args );
14 0           push @{$self->_subscribed}, [ $source, @args ];
  0            
15 0           foreach my $ref ( @{$self->_subscribed->[-1]} ) {
  0            
16 0 0         next unless ref $ref;
17 0           weaken( $ref );
18             }
19             }
20              
21             sub delete_subscriptions {
22 0     0 0   my( $self ) = @_;
23              
24 0 0         foreach my $sub ( @{$self->_subscribed || []} ) {
  0            
25 0 0 0       next unless $sub->[0] && $sub->[1]; # might have been destroyed
26 0           $sub->[0]->delete_subscriber( @$sub[1 .. $#$sub] );
27             }
28 0           $self->_subscribed( undef );
29             }
30              
31             1;