line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id: /mirror/coderepos/lang/perl/Class-DBI-Plugin-DateTime/trunk/lib/Class/DBI/Plugin/DateTime/Base.pm 101061 2009-02-20T09:44:03.572989Z daisuke $ |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# Copyright (c) 2005 Daisuke Maki |
4
|
|
|
|
|
|
|
# All rights reserved. |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
package Class::DBI::Plugin::DateTime::Base; |
7
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
32
|
|
8
|
1
|
|
|
1
|
|
636
|
use DateTime; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub import |
11
|
|
|
|
|
|
|
{ |
12
|
|
|
|
|
|
|
my $class = shift; |
13
|
|
|
|
|
|
|
$class->SUPER::import(@_); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my($caller) = caller(); |
16
|
|
|
|
|
|
|
$class->_do_export($caller); |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub _export_methods { return () } |
20
|
|
|
|
|
|
|
sub _do_export |
21
|
|
|
|
|
|
|
{ |
22
|
|
|
|
|
|
|
my $class = shift; |
23
|
|
|
|
|
|
|
my $caller = shift; |
24
|
|
|
|
|
|
|
my @methods = $class->_export_methods(); |
25
|
|
|
|
|
|
|
foreach my $method (@methods) { |
26
|
|
|
|
|
|
|
no strict 'refs'; |
27
|
|
|
|
|
|
|
*{"${caller}::${method}"} = *{"${class}::${method}"}; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub _setup_column |
32
|
|
|
|
|
|
|
{ |
33
|
|
|
|
|
|
|
my $class = shift; |
34
|
|
|
|
|
|
|
my $target = shift; |
35
|
|
|
|
|
|
|
my $column = shift; |
36
|
|
|
|
|
|
|
my $inflate = shift; |
37
|
|
|
|
|
|
|
my $deflate = shift; |
38
|
|
|
|
|
|
|
my $coltype = shift || 'DateTime'; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
if (! $target->can('has_lazy')) { |
41
|
|
|
|
|
|
|
eval <<" EOM"; |
42
|
|
|
|
|
|
|
package $target; |
43
|
|
|
|
|
|
|
use Class::DBI::LazyInflate; |
44
|
|
|
|
|
|
|
EOM |
45
|
|
|
|
|
|
|
die if $@; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
$target->has_lazy( |
49
|
|
|
|
|
|
|
$column => $coltype, |
50
|
|
|
|
|
|
|
inflate => $inflate, |
51
|
|
|
|
|
|
|
deflate => $deflate, |
52
|
|
|
|
|
|
|
); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
__END__ |