File Coverage

blib/lib/Error/Hierarchy/Container.pm
Criterion Covered Total %
statement 22 45 48.8
branch 0 2 0.0
condition n/a
subroutine 8 12 66.6
pod 5 5 100.0
total 35 64 54.6


line stmt bran cond sub pod time code
1 2     2   77862 use 5.008;
  2         8  
  2         84  
2 2     2   12 use strict;
  2         5  
  2         61  
3 2     2   10 use warnings;
  2         4  
  2         115  
4              
5             package Error::Hierarchy::Container;
6             BEGIN {
7 2     2   48 $Error::Hierarchy::Container::VERSION = '1.103530';
8             }
9              
10 2     2   2346 use Class::Trigger;
  2         3066  
  2         12  
11 2     2   687 use Error::Hierarchy::Util 'load_class';
  2         5  
  2         132  
12              
13             # ABSTRACT: Container for hierarchical exceptions
14 2         14 use parent qw(
15             Data::Container
16             Error::Hierarchy::Base
17 2     2   868 );
  2         310  
18              
19             sub items_push {
20 2     2 1 263 my ($self, @values) = @_;
21 2         15 $self->call_trigger('before_push', @values);
22 2         1083 $self->SUPER::items_push(@values);
23              
24             }
25              
26             sub items_set_push {
27 0     0 1   my ($self, @values) = @_;
28              
29             # Some methods won't work on non-E-H objects; report them so they appear
30             # directly - e.g., in the error.log if running under mod_perl
31 0           $self->call_trigger('before_push', @values);
32 0           $self->SUPER::items_set_push(@values);
33             }
34              
35             sub record {
36 0     0 1   my ($self, $exception_class, %args) = @_;
37              
38 0           load_class $exception_class, 1;
39             # make record() invisible to caller when reporting exception location
40 0           local $Error::Depth = $Error::Depth + 1;
41 0           $self->items_set_push($exception_class->record(%args));
42             }
43              
44             # Given a list of uuid's, deletes all exceptions from the container whose uuid
45             # is one of those given.
46             sub delete_by_uuid {
47 0     0 1   my ($self, @uuid) = @_;
48 0           my %uuid;
49 0           @uuid{@uuid} = ();
50 0           $self->items(grep { !exists $uuid{$_} } $self->items);
  0            
51             }
52              
53             sub delete_duplicate_exceptions {
54 0     0 1   my $self = shift;
55 0           my @items;
56             my %seen;
57 0           for my $exception ($self->items) {
58 0           my %properties = $exception->properties_as_hash;
59 0           $properties{__package} = ref $exception;
60 0           my $signature =
61 0           join ';' => map { $_ => $properties{$_} } sort keys %properties;
62 0 0         next if $seen{$signature}++;
63 0           push @items => $exception;
64             }
65 0           $self->items(@items);
66 0           $self;
67             }
68             1;
69              
70              
71             __END__