line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Nitesi::Class; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
11
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
66
|
|
4
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
450
|
|
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
|
|
|
|
|
|
|
sub instantiate { |
23
|
1
|
|
|
1
|
1
|
4
|
my ($self, $class, @args) = @_; |
24
|
1
|
|
|
|
|
2
|
my ($object); |
25
|
|
|
|
|
|
|
|
26
|
1
|
|
|
|
|
110
|
eval "require $class"; |
27
|
|
|
|
|
|
|
|
28
|
1
|
50
|
|
|
|
8
|
if ($@) { |
29
|
0
|
|
|
|
|
0
|
die "failed to load class $class: $@"; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
1
|
|
|
|
|
2
|
eval { |
33
|
1
|
|
|
|
|
5
|
$object = $class->new(@args); |
34
|
|
|
|
|
|
|
}; |
35
|
|
|
|
|
|
|
|
36
|
1
|
50
|
|
|
|
3802
|
if ($@) { |
37
|
0
|
|
|
|
|
0
|
die "failed to instantiate class $class: $@"; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
1
|
|
|
|
|
7
|
return $object; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head2 load |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Loads class. |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=cut |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub load { |
50
|
0
|
|
|
0
|
1
|
|
my ($self, $class) = @_; |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
eval "require $class"; |
53
|
|
|
|
|
|
|
|
54
|
0
|
0
|
|
|
|
|
if ($@) { |
55
|
0
|
|
|
|
|
|
die "failed to load class $class: $@"; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 AUTHOR |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Stefan Hornburg (Racke), |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Copyright 2011-2013 Stefan Hornburg (Racke) . |
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
|
|
|
|
|
|
|
1; |