File Coverage

blib/lib/Eidolon/Core/Exception/Builder.pm
Criterion Covered Total %
statement 99 99 100.0
branch 3 6 50.0
condition 2 2 100.0
subroutine 30 30 100.0
pod n/a
total 134 137 97.8


line stmt bran cond sub pod time code
1             package Eidolon::Core::Exception::Builder;
2             # ==============================================================================
3             #
4             # Eidolon
5             # Copyright (c) 2009, Atma 7
6             # ---
7             # Eidolon/Core/Exception/Builder.pm - exception builder
8             #
9             # ==============================================================================
10              
11 9     9   2710 use warnings;
  9         19  
  9         246  
12 9     9   45 use strict;
  9         13  
  9         1123  
13              
14             our $VERSION = "0.02"; # 2009-05-12 06:24:56
15              
16             # ------------------------------------------------------------------------------
17             # import($class, $data)
18             # create exceptions classes
19             # ------------------------------------------------------------------------------
20             sub import
21             {
22 17     17   39 my ($self, $class, $data, $isa, $title, $code);
23              
24 17         28 $self = shift;
25              
26 17         81 while ($class = shift)
27             {
28 63 50       331 $data = ref $_[0] ? shift : {};
29 63   100     229 $isa = $data->{"isa"} || "Eidolon::Core::Exception";
30 63         104 $title = $data->{"title"};
31              
32             # check if base class exists
33             {
34 9     9   47 no strict "refs";
  9         16  
  9         1209  
  63         80  
35 63 50       113 die "Base class doesn't exist: $isa" if (!keys %{"$isa\::"});
  63         254  
36             }
37              
38 63         143 $code = "package $class;\nuse base qw/$isa/;\n";
39 63 50       197 $code .= "use constant TITLE => '$title';\n" if ($title);
40              
41 9     9   52 eval $code;
  9     9   16  
  9     9   5275  
  9     9   59  
  9     8   18  
  9     8   601  
  9     8   47  
  9     8   18  
  9     7   5401  
  9     7   56  
  9     3   19  
  9     3   476  
  8     3   43  
  8     3   29  
  8     3   13978  
  8     3   57  
  8     3   19  
  8     3   329  
  8     3   132  
  8     3   15  
  8     3   5094  
  8     3   54  
  8     3   16  
  8     3   326  
  7     1   38  
  7     1   10  
  7         4154  
  7         54  
  7         15  
  7         453  
  3         15  
  3         6  
  3         1412  
  3         15  
  3         7  
  3         102  
  3         18  
  3         5  
  3         1500  
  3         18  
  3         8  
  3         161  
  3         18  
  3         4  
  3         1518  
  3         18  
  3         14  
  3         114  
  3         18  
  3         13  
  3         1479  
  3         18  
  3         29  
  3         291  
  3         18  
  3         5  
  3         1703  
  3         20  
  3         10  
  3         114  
  3         17  
  3         11  
  3         1538  
  3         21  
  3         5  
  3         111  
  3         17  
  3         5  
  3         1585  
  3         18  
  3         7  
  3         232  
  1         6  
  1         1  
  1         76  
  1         6  
  1         1  
  1         75  
  63         6827  
42             }
43             }
44              
45             1;
46              
47             __END__