Nitesi/Class.pm

filter: Statementstmt 71.4% 15 / 21 Branchbran 33.3% 2 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 75.0% 3 / 4 Podpod 100% 2 / 2 totaltotal 66.6% 22 / 33 CC 4 SCAR 12.2
CC
4
Cov
63%
load
6.0
instantiate
3.2
BEGIN
1.0
CRAP 3.4
« Nitesi/Account/Provider/Test.pm ↑ Summary Nitesi/Address.pm »
1 package Nitesi::Class;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 =head1 NAME
7  
8 Nitesi::Class - Instantiate objects at runtime
9  
10 =head1 SYNOPSIS
11  
12 Nitesi::Class->instantiate('My::Nitesi::Extension', foo => 'bar')
13  
14 =head1 METHODS
15  
16 =head2 instantiate
17  
18 Loads class and instantiates object with optional parameters.
19  
20 =cut
21  
22 3 ▶sub instantiate {
Subroutine instantiate: called CC=3 SCAR=11.7
Pod documented
23 3 my ($self, $class, @args) = @_;
24 3 my ($object);
25  
26 3 eval "require $class";
27  
28 3 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 3 3
29 0 die "failed to load class $class: $@";
30 }
31  
32 3 eval {
33 3 $object = $class->new(@args);
34 };
35  
36 3 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 3 3
37 0 die "failed to instantiate class $class: $@";
38 }
39  
40 3 return $object;
41 }
42  
43 =head2 load
44  
45 Loads class.
46  
47 =cut
48  
49 0 ▶sub load {
Subroutine load: not called CC=2 SCAR=17.9
Pod documented
50 0 my ($self, $class) = @_;
51  
52 0 eval "require $class";
53  
54 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
55 0 die "failed to load class $class: $@";
56 }
57 }
58  
59 =head1 AUTHOR
60  
61 Stefan Hornburg (Racke), <racke@linuxia.de>
62  
63 =head1 LICENSE AND COPYRIGHT
64  
65 Copyright 2011-2013 Stefan Hornburg (Racke) <racke@linuxia.de>.
66  
67 This program is free software; you can redistribute it and/or modify it
68 under the terms of either: the GNU General Public License as published
69 by the Free Software Foundation; or the Artistic License.
70  
71 See http://dev.perl.org/licenses/ for more information.
72  
73 =cut
74  
75 2 1;
« Nitesi/Account/Provider/Test.pm ↑ Summary Nitesi/Address.pm »