Catalyst-Plugin-CRUD
view release on metacpan or search on metacpan
lib/Catalyst/Plugin/CRUD.pm view on Meta::CPAN
package MyApp::Controller::Foo;
sub create : Local {
my ($self, $c) = @_;
$c->create($self);
}
1;
=head1 DESCRIPTION
This module provides CRUD (create/read/update/delete) action.
create: insert new record
read: retrieve record
update: update already record
delete: delete record
list: retrieve all records
=head2 EXPORT
None by default.
=head1 METHODS
=head2 create
Create action.
This method internally calls Catalyst::Controller::[CDBI|DBIC]::create.
=cut
sub create {
my ( $c, $self ) = @_;
my $type = $self->setting($c)->{type} || 'CDBI';
my $cntl = "Catalyst::Controller::CRUD::" . $type;
$cntl->create($c, $self);
}
=head2 read
Read action.
This method internally calls Catalyst::Controller::[CDBI|DBIC]::read.
=cut
sub read {
my ( $c, $self ) = @_;
my $type = $self->setting($c)->{type} || 'CDBI';
my $cntl = "Catalyst::Controller::CRUD::" . $type;
$cntl->read($c, $self);
}
=head2 update
Update action.
This method internally calls Catalyst::Controller::[CDBI|DBIC]::update.
=cut
sub update {
my ( $c, $self ) = @_;
my $type = $self->setting($c)->{type} || 'CDBI';
my $cntl = "Catalyst::Controller::CRUD::" . $type;
$cntl->update($c, $self);
}
=head2 delete
Delete action.
This method internally calls Catalyst::Controller::[CDBI|DBIC]::delete.
=cut
sub delete {
my ( $c, $self ) = @_;
my $type = $self->setting($c)->{type} || 'CDBI';
my $cntl = "Catalyst::Controller::CRUD::" . $type;
$cntl->delete($c, $self);
}
=head2 list
List action
This method internally calls Catalyst::Controller::[CDBI|DBIC]::list.
=cut
sub list {
my ( $c, $self ) = @_;
my $type = $self->setting($c)->{type} || 'CDBI';
my $cntl = "Catalyst::Controller::CRUD::" . $type;
$cntl->list($c, $self);
}
=head2 Class::DBI::toHashRef
=cut
sub Class::DBI::toHashRef {
my ( $self ) = @_;
my %hash = $self->_as_hash;
return \%hash;
}
=head2 DBIx::Class::toHashRef
=cut
sub DBIx::Class::toHashRef {
my ( $self ) = @_;
# see http://search.cpan.org/dist/DBIx-Class-AsFdat
my $hash;
for my $column ($self->result_source->columns) {
$hash->{$column} = $self->$column;
# inflate the datetime
if (blessed($hash->{$column}) and $hash->{$column}->isa('DateTime')) {
for my $type (qw(year month day hour minute second)) {
( run in 0.650 second using v1.01-cache-2.11-cpan-39bf76dae61 )