line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#======================================================================== |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# Badger::Prototype |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# DESCRIPTION |
6
|
|
|
|
|
|
|
# Base class module for a protoype class that has a default instance |
7
|
|
|
|
|
|
|
# that can be created on demand. |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
# AUTHOR |
10
|
|
|
|
|
|
|
# Andy Wardley |
11
|
|
|
|
|
|
|
# |
12
|
|
|
|
|
|
|
#======================================================================== |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
package Badger::Prototype; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
use Badger::Class |
17
|
70
|
|
|
|
|
805
|
base => 'Badger::Base', |
18
|
|
|
|
|
|
|
version => 0.01, |
19
|
|
|
|
|
|
|
debug => 0, |
20
|
|
|
|
|
|
|
constants => 'PKG REFS ONCE', |
21
|
70
|
|
|
70
|
|
460
|
words => 'PROTOTYPE'; |
|
70
|
|
|
|
|
120
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub prototype { |
24
|
6316
|
|
|
6316
|
1
|
7378
|
my $class = shift; |
25
|
6316
|
100
|
|
|
|
12805
|
return $class if ref $class; |
26
|
70
|
|
|
70
|
|
472
|
no strict REFS; |
|
70
|
|
|
|
|
149
|
|
|
70
|
|
|
|
|
2115
|
|
27
|
70
|
|
|
70
|
|
336
|
no warnings ONCE; |
|
70
|
|
|
|
|
122
|
|
|
70
|
|
|
|
|
10567
|
|
28
|
|
|
|
|
|
|
|
29
|
2034
|
100
|
66
|
|
|
5866
|
if (@_ == 1 && ! defined $_[0]) { |
|
|
100
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# if only a single undef argument is provided, then clear any |
31
|
|
|
|
|
|
|
# prototype from $PROTOTYPE and return a reference to it. |
32
|
1
|
|
|
|
|
3
|
my $proto = ${$class.PKG.PROTOTYPE}; |
|
1
|
|
|
|
|
4
|
|
33
|
1
|
|
|
|
|
1
|
undef ${$class.PKG.PROTOTYPE}; |
|
1
|
|
|
|
|
3
|
|
34
|
1
|
|
|
|
|
3
|
return $proto; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
elsif (@_) { |
37
|
|
|
|
|
|
|
# if any other arguments are provided then it forces us to create |
38
|
|
|
|
|
|
|
# a new prototype with the fresh configuration options. |
39
|
1
|
|
|
|
|
2
|
undef ${$class.PKG.PROTOTYPE}; |
|
1
|
|
|
|
|
4
|
|
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# return the cached value (assuming we didn't just clear it) or create |
43
|
|
|
|
|
|
|
# a new one (if we did, or if there wasn't a previous value) |
44
|
2033
|
|
66
|
|
|
2220
|
return ${$class.PKG.PROTOTYPE} ||= $class->new(@_); |
|
2033
|
|
|
|
|
9169
|
|
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub has_prototype { |
48
|
2
|
|
|
2
|
1
|
12
|
my $self = shift; |
49
|
2
|
|
33
|
|
|
7
|
my $class = ref $self || $self; |
50
|
70
|
|
|
70
|
|
457
|
no strict REFS; |
|
70
|
|
|
|
|
115
|
|
|
70
|
|
|
|
|
2275
|
|
51
|
70
|
|
|
70
|
|
390
|
no warnings ONCE; |
|
70
|
|
|
|
|
160
|
|
|
70
|
|
|
|
|
4853
|
|
52
|
2
|
|
|
|
|
3
|
defined ${$class.PKG.PROTOTYPE}; |
|
2
|
|
|
|
|
13
|
|
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
1; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
__END__ |