line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Elive::DAO::_Base; |
2
|
36
|
|
|
36
|
|
22162
|
use warnings; use strict; |
|
36
|
|
|
36
|
|
85
|
|
|
36
|
|
|
|
|
1040
|
|
|
36
|
|
|
|
|
521
|
|
|
36
|
|
|
|
|
71
|
|
|
36
|
|
|
|
|
1243
|
|
3
|
|
|
|
|
|
|
|
4
|
36
|
|
|
36
|
|
202
|
use parent qw{Class::Data::Inheritable}; |
|
36
|
|
|
|
|
186
|
|
|
36
|
|
|
|
|
336
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
Elive::DAO::_Base - Base class for DAO objects |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=cut |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $DEBUG; |
13
|
|
|
|
|
|
|
BEGIN { |
14
|
36
|
|
|
36
|
|
13293
|
$DEBUG = $ENV{ELIVE_DEBUG}; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub debug { |
18
|
379
|
|
|
379
|
0
|
600
|
my ($class, $level) = @_; |
19
|
|
|
|
|
|
|
|
20
|
379
|
50
|
|
|
|
849
|
if (defined $level) { |
21
|
0
|
|
|
|
|
0
|
$DEBUG = $level; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
379
|
|
50
|
|
|
3089
|
return $DEBUG || 0; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub _refaddr { |
28
|
636
|
|
|
636
|
|
798
|
my $self = shift; |
29
|
636
|
|
|
|
|
2252
|
return Scalar::Util::refaddr( $self ); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
our %Meta_Data; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# |
35
|
|
|
|
|
|
|
# create metadata properties. NB this will be stored inside out to |
36
|
|
|
|
|
|
|
# ensure our object is an exact image of the data. |
37
|
|
|
|
|
|
|
# |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head2 has_metadata |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Associate an inside-out property with objects of a given class. |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=cut |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub has_metadata { |
46
|
|
|
|
|
|
|
|
47
|
150
|
|
|
150
|
1
|
272
|
my $class = shift; |
48
|
150
|
|
|
|
|
279
|
my $accessor = shift; |
49
|
|
|
|
|
|
|
|
50
|
150
|
|
|
|
|
858
|
my $accessor_fun = $class->can($accessor); |
51
|
|
|
|
|
|
|
|
52
|
150
|
50
|
|
|
|
493
|
unless ($accessor_fun) { |
53
|
|
|
|
|
|
|
|
54
|
36
|
|
|
36
|
|
213
|
no strict 'refs'; |
|
36
|
|
|
|
|
63
|
|
|
36
|
|
|
|
|
9878
|
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
$accessor_fun = sub { |
57
|
318
|
|
|
318
|
|
417
|
my $self = shift; |
58
|
318
|
50
|
|
|
|
615
|
my $ref = $self->_refaddr |
59
|
|
|
|
|
|
|
or return; |
60
|
|
|
|
|
|
|
|
61
|
318
|
50
|
|
|
|
725
|
if (@_) { |
62
|
0
|
|
|
|
|
0
|
$Meta_Data{ $ref }{ $accessor } = $_[0]; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
318
|
|
|
|
|
2483
|
return $Meta_Data{ $ref }{ $accessor }; |
66
|
150
|
|
|
|
|
642
|
}; |
67
|
|
|
|
|
|
|
|
68
|
150
|
|
|
|
|
243
|
*{$class.'::'.$accessor} = $accessor_fun; |
|
150
|
|
|
|
|
544
|
|
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
150
|
|
|
|
|
457
|
return $accessor_fun; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
__PACKAGE__->mk_classdata('_connection'); |
75
|
|
|
|
|
|
|
__PACKAGE__->has_metadata('_object_connection'); |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub connection { |
78
|
1
|
|
|
1
|
0
|
3
|
my $self = shift; |
79
|
1
|
|
|
|
|
2
|
my $connection; |
80
|
1
|
50
|
|
|
|
6
|
$connection = $self->_object_connection(@_) |
81
|
|
|
|
|
|
|
if ref $self; |
82
|
1
|
|
33
|
|
|
18
|
$connection ||= $self->_connection(@_); |
83
|
1
|
|
|
|
|
16
|
return $connection; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub DEMOLISH { |
87
|
318
|
|
|
318
|
0
|
483
|
my $self = shift; |
88
|
318
|
|
|
|
|
656
|
delete $Meta_Data{ $self->_refaddr }; |
89
|
318
|
|
|
|
|
2256
|
return; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
1; |