From: Johannes Plunien Date: Sat, 25 Oct 2008 03:11:43 +0000 (+0200) Subject: rafl refactored last changes X-Git-Tag: v0.08240~307 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=bb90689c4ee23f5407732eda3937553247285b0d;p=dbsrgits%2FDBIx-Class.git rafl refactored last changes --- diff --git a/lib/DBIx/Class/InflateColumn/DateTime.pm b/lib/DBIx/Class/InflateColumn/DateTime.pm index 17567be..393a178 100644 --- a/lib/DBIx/Class/InflateColumn/DateTime.pm +++ b/lib/DBIx/Class/InflateColumn/DateTime.pm @@ -88,10 +88,24 @@ sub register_column { my ($self, $column, $info, @rest) = @_; $self->next::method($column, $info, @rest); return unless defined($info->{data_type}); - my $type = lc($info->{data_type}); - $type = 'datetime' if ($type =~ /^timestamp/); - $type = 'datetime' if $info->{inflate_datetime}; - $type = 'date' if $info->{inflate_date}; + + my $type; + + for (qw/date datetime/) { + my $key = "inflate_${_}"; + + next unless exists $info->{$key}; + return unless $info->{$key}; + + $type = $_; + last; + } + + unless ($type) { + $type = lc($info->{data_type}); + $type = 'datetime' if ($type =~ /^timestamp/); + } + my $timezone; if ( exists $info->{extra} and exists $info->{extra}{timezone} and defined $info->{extra}{timezone} ) { $timezone = $info->{extra}{timezone}; @@ -99,11 +113,7 @@ sub register_column { my $undef_if_invalid = $info->{datetime_undef_if_invalid}; - my $do_inflate = 1; - $do_inflate = 0 if exists $info->{inflate_datetime} and $info->{inflate_datetime} == 0; - $do_inflate = 0 if exists $info->{inflate_date} and $info->{inflate_date} == 0; - - if ($do_inflate and ($type eq 'datetime' || $type eq 'date')) { + if ($type eq 'datetime' || $type eq 'date') { my ($parse, $format) = ("parse_${type}", "format_${type}"); $self->inflate_column( $column =>