| 1 | # $Id: /mirror/coderepos/lang/perl/Class-DBI-Plugin-DateTime/trunk/lib/Class/DBI/Plugin/DateTime/MySQL.pm 101061 2009-02-20T09:44:03.572989Z daisuke $ | ||||||||||
| 2 | # | ||||||||||
| 3 | # Copyright (c) 2005 Daisuke Maki <dmaki@cpan.org> | ||||||||||
| 4 | # All rights reserved. | ||||||||||
| 5 | |||||||||||
| 6 | package Class::DBI::Plugin::DateTime::MySQL; | ||||||||||
| 7 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 2 | ▶ | use base qw(Class::DBI::Plugin::DateTime::Base); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 2 | ▶ | use DateTime::Format::MySQL; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | BEGIN | ||||||||||
| 12 | 2 | ▶ | { | ||||||||
|
Subroutine
BEGIN: called CC=3 SCAR=15.4
| |||||||||||
| 13 | 2 | my @types = qw(datetime date timestamp); | |||||||||
| 14 | 2 | foreach my $type (@types) { | |||||||||
| 15 | # DT::F::MySQL doesn't have a format_timestamp method, so change | ||||||||||
| 16 | # the deflator method accordingly | ||||||||||
| 17 | 6 | my($inflator, $deflator); | |||||||||
| 18 | 6 | ▶ | if ($type eq 'timestamp') { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 19 | 2 | $inflator = 'timestamp'; | |||||||||
| 20 | 2 | $deflator = 'datetime'; | |||||||||
| 21 | } else { | ||||||||||
| 22 | 4 | $inflator = $type; | |||||||||
| 23 | 4 | $deflator = $type; | |||||||||
| 24 | } | ||||||||||
| 25 | |||||||||||
| 26 | 0 | ▶ | eval sprintf(<<' EOM', $type, $inflator, $deflator); | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.3
Subroutine
__ANON__: not called CC=1 SCAR=6.3
Subroutine
__ANON__: not called CC=1 SCAR=6.3
Subroutine
__ANON__: not called CC=1 SCAR=6.3
Subroutine
__ANON__: not called CC=1 SCAR=6.3
Subroutine
__ANON__: not called CC=1 SCAR=6.3
Subroutine
has_date: not called CC=1 SCAR=6.3
Subroutine
has_datetime: not called CC=1 SCAR=6.3
Subroutine
has_timestamp: not called CC=1 SCAR=6.3
Pod
documented
Pod
documented
Pod
documented
| |||||||||||
| 27 | sub has_%s | ||||||||||
| 28 | { | ||||||||||
| 29 | my $class = shift; | ||||||||||
| 30 | my $column = shift; | ||||||||||
| 31 | |||||||||||
| 32 | my $inflate = sub { DateTime::Format::MySQL->parse_%s(shift) }; | ||||||||||
| 33 | my $deflate = sub { DateTime::Format::MySQL->format_%s(shift) }; | ||||||||||
| 34 | __PACKAGE__->_setup_column($class, $column, $inflate, $deflate); | ||||||||||
| 35 | } | ||||||||||
| 36 | EOM | ||||||||||
| 37 | } | ||||||||||
| 38 | |||||||||||
| 39 | { | ||||||||||
| 40 | 2 | my @methods = map { ("has_$_") } @types; | |||||||||
| 41 | 2 | ▶ | *_export_methods = sub { @methods }; | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 42 | } | ||||||||||
| 43 | } | ||||||||||
| 44 | |||||||||||
| 45 | 2 | 1; | |||||||||
| 46 | |||||||||||
| 47 | __END__ | ||||||||||