Show
Ignore:
Timestamp:
06/14/08 14:17:06 (5 years ago)
Author:
tokuhirom
Message:

use exporter.

Location:
lang/perl/Class-DBI-Plugin-AsFdat/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/Class-DBI-Plugin-AsFdat/trunk/Makefile.PL

    r13861 r13864  
    66requires 'Class::DBI'      => '3.0.11'; 
    77requires 'DateTime'        => 0.2901; 
     8requires 'Exporter'        => 5.62; 
    89 
    910test_requires 'Test::More'; 
  • lang/perl/Class-DBI-Plugin-AsFdat/trunk/lib/Class/DBI/Plugin/AsFdat.pm

    r13859 r13864  
    33use warnings; 
    44our $VERSION = '0.02'; 
     5use Exporter 'import'; 
    56use Scalar::Util qw/blessed/; 
    67 
    7 sub import { 
    8     my $class = shift; 
    9     my $pkg   = caller(0); 
     8our @EXPORT = qw(as_fdat); 
    109 
    11     no strict 'refs'; 
    12     *{"$pkg\::as_fdat"} = sub { 
    13         my $self = shift; 
     10sub as_fdat { 
     11    my $self = shift; 
    1412 
    15         my $fdat; 
    16         for my $column ($self->columns) { 
    17             $fdat->{$column} = $self->get($column); 
     13    my $fdat; 
     14    for my $column ($self->columns) { 
     15        $fdat->{$column} = $self->get($column); 
    1816 
    19             # inflate the datetime 
    20             if (blessed $fdat->{$column} and $fdat->{$column}->isa('DateTime')) { 
    21                 for my $type (qw(year month day hour minute second)) { 
    22                     $fdat->{"${column}_$type"}  = $fdat->{$column}->$type; 
    23                 } 
     17        # inflate the datetime 
     18        if (blessed $fdat->{$column} and $fdat->{$column}->isa('DateTime')) { 
     19            for my $type (qw(year month day hour minute second)) { 
     20                $fdat->{"${column}_$type"}  = $fdat->{$column}->$type; 
    2421            } 
    2522        } 
    26         return $fdat; 
    27     }; 
     23    } 
     24    return $fdat; 
    2825} 
    2926 
     
    5249`fdat' is data for HTML::FillInForm. 
    5350 
     51=head1 METHODS 
     52 
     53=over 4 
     54 
     55=item as_fdat 
     56 
     57transform cdbi row instance to hashref. 
     58 
     59=back 
     60 
    5461=head1 AUTHOR 
    5562