line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id: LazyInflate.pm 7 2005-06-01 06:36:24Z daisuke $ |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# Copyright (c) 2004-2005 Daisuke Maki |
4
|
|
|
|
|
|
|
# All rights reserved. |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
package Class::DBI::LazyInflate; |
7
|
1
|
|
|
1
|
|
867
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
36
|
|
8
|
1
|
|
|
1
|
|
2021
|
use Class::DBI; |
|
1
|
|
|
|
|
80667
|
|
|
1
|
|
|
|
|
9
|
|
9
|
1
|
|
|
1
|
|
788
|
use Data::Lazy; |
|
1
|
|
|
|
|
2970
|
|
|
1
|
|
|
|
|
6
|
|
10
|
1
|
|
|
1
|
|
70
|
use vars qw($VERSION); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
56
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
BEGIN |
13
|
|
|
|
|
|
|
{ |
14
|
1
|
|
|
1
|
|
35
|
$VERSION = '0.06'; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub import |
18
|
|
|
|
|
|
|
{ |
19
|
1
|
|
|
1
|
|
11
|
my $class = shift; |
20
|
1
|
|
|
|
|
3
|
my($caller) = caller(); |
21
|
|
|
|
|
|
|
{ |
22
|
1
|
|
|
1
|
|
6
|
no strict 'refs'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
194
|
|
|
1
|
|
|
|
|
2
|
|
23
|
1
|
|
|
|
|
3
|
*{ "${caller}::has_lazy" } = \&has_lazy; |
|
1
|
|
|
|
|
16
|
|
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub has_lazy |
28
|
|
|
|
|
|
|
{ |
29
|
0
|
|
|
0
|
1
|
|
my($class, $column, $colclass, %args) = @_; |
30
|
|
|
|
|
|
|
|
31
|
0
|
|
0
|
|
|
|
my $inflate = $args{inflate} || |
32
|
|
|
|
|
|
|
($colclass->isa('Class::DBI') ? '_simple_bless' : 'new'); |
33
|
|
|
|
|
|
|
my $lazy_inflate = sub { |
34
|
0
|
|
|
0
|
|
|
my @args = @_; |
35
|
|
|
|
|
|
|
tie $_[0], 'Data::Lazy', |
36
|
|
|
|
|
|
|
sub { |
37
|
0
|
0
|
|
|
|
|
ref($inflate) eq 'CODE' ? |
38
|
|
|
|
|
|
|
$inflate->(@args) : |
39
|
|
|
|
|
|
|
$colclass->$inflate(@args) }, |
40
|
0
|
|
|
|
|
|
LAZY_STOREVALUE; |
41
|
0
|
|
|
|
|
|
$_[0]; |
42
|
0
|
|
|
|
|
|
}; |
43
|
0
|
|
|
|
|
|
$class->has_a( |
44
|
|
|
|
|
|
|
$column, $colclass, |
45
|
|
|
|
|
|
|
inflate => $lazy_inflate, deflate => $args{deflate} |
46
|
|
|
|
|
|
|
); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
__END__ |