Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

nekokak (7400)

nekokak
  (email not shown publicly)
http://d.hatena.ne.jp/nekokak/

Journal of nekokak (7400)

Wednesday November 01, 2006
02:01 AM

I wrote DBIx::Class::AsFdat

[ #31465 ]

I wrote DBIx::Class::AsFdat.

DBIx::Class::AsFdat like Class::DBI::Plugin::AsFdat.

package DBIx::Class::AsFdat;
use strict;
use warnings;
use base 'DBIx::Class';
use Scalar::Util qw/blessed/;
 
our $VERSION = 0.01;
 
sub as_fdat {
    my $self = shift;
 
    my $fdat;
    for my $column ($self->result_source->columns) {
        $fdat->{$column} = $self->$column;
 
        # inflate the datetime
        if (blessed $fdat->{$column} and $fdat->{$column}->isa('DateTime')) {
            for my $type (qw(year month day hour minute second)) {
                $fdat->{"${column}_$type"}  = $fdat->{$column}->$type;
            }
        }
    }
    return $fdat;
}
 
1;
 
__END__
 
=head1 SYNOPSIS
 
    __PACKAGE__->load_components(qw/
        AsFdat
    /);
 
    my $ad = $self->model('Ad')->search(rid => $self->r->param('ad_rid'))->first;
    $self->fillin_form->fdat($ad->as_fdat);

HTML::FillInForm and compatibility are good.
It is indispensable in Web Application.
enjoy!!

PS.
However, this module is not released to CPAN.