File Coverage

blib/lib/Class/Scaffold/YAML/Marshall/ExceptionContainer.pm
Criterion Covered Total %
statement 16 24 66.6
branch n/a
condition n/a
subroutine 6 7 85.7
pod 1 1 100.0
total 23 32 71.8


line stmt bran cond sub pod time code
1 2     2   34 use 5.008;
  2         7  
  2         118  
2 2     2   13 use warnings;
  2         4  
  2         52  
3 2     2   22 use strict;
  2         3  
  2         107  
4              
5             package Class::Scaffold::YAML::Marshall::ExceptionContainer;
6             BEGIN {
7 2     2   48 $Class::Scaffold::YAML::Marshall::ExceptionContainer::VERSION = '1.102280';
8             }
9             # ABSTRACT: Marshalling plugin that constructs an exception container
10 2     2   16 use YAML::Marshall 'exception/container';
  2         2  
  2         20  
11 2     2   94 use parent 'Class::Scaffold::YAML::Marshall';
  2         3  
  2         15  
12              
13             sub yaml_load {
14 0     0 1   my $self = shift;
15 0           my $node = $self->SUPER::yaml_load(@_);
16              
17             # Expect a list of hashrefs; each hash element is an exception with a
18             # 'ref' key giving the exception class, and the rest being treated as args
19             # to give to the exception when it is being recorded. Example:
20             #
21             # exception_container: !perl/Class::Scaffold::YAML::Active::ExceptionContainer
22             # - ref: Class::Scaffold::Exception::Policy::Blah
23             # property1: value1
24             # property2: value2
25 0           my $container = $self->delegate->make_obj('exception_container');
26 0           for my $exception (@$node) {
27              
28             # Copy because we delete (so as to not mess up YAML references)
29 0           my %args = %$exception;
30 0           my $class = delete $args{ref};
31 0           $container->record($class, %args);
32             }
33 0           $container;
34             }
35             1;
36              
37              
38             __END__