| 1 | { package Catalyst::Controller::DBIC::Transaction; | ||
| 2 | |||
| 3 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 1 | ▶ | use base 'Catalyst::Controller'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | our $VERSION = '0.4'; | ||
| 8 | |||
| 9 | __PACKAGE__->mk_accessors qw(_dbic_transaction_schemas); | ||
| 10 | |||
| 11 | sub _parse_DBICTransaction_attr { | ||
| 12 | my ($self, $c, $name, $value) = @_; | ||
| 13 | |||
| 14 | $self->_dbic_transaction_schemas({}) unless | ||
| 15 | $self->_dbic_transaction_schemas(); | ||
| 16 | |||
| 17 | $self->_dbic_transaction_schemas->{$name} = $value; | ||
| 18 | |||
| 19 | ( ActionClass => 'Catalyst::Action::DBIC::Transaction' ); | ||
| 20 | } | ||
| 21 | |||
| 22 | }; | ||
| 23 | 1; | ||
| 24 | |||
| 25 | =head1 NAME | ||
| 26 | |||
| 27 | Catalyst::Controller::DBIC::Transaction - Encloses actions into transactions | ||
| 28 | |||
| 29 | =head1 SYNOPSIS | ||
| 30 | |||
| 31 | use base qw(Catalyst::Controller::DBIC::Transaction); | ||
| 32 | sub foo :DBICTransaction('DB') { | ||
| 33 | do $something or die $!; | ||
| 34 | } | ||
| 35 | |||
| 36 | =head1 DESCRIPTION | ||
| 37 | |||
| 38 | THIS MODULE SHOULD BE CONSIDERED DEPRECATED. What is currently | ||
| 39 | understood as a better practice is to enclose the code requiring a | ||
| 40 | transaction into a proper model class. The point is that business | ||
| 41 | logic should not be in the controller. | ||
| 42 | |||
| 43 | This module enables the use of automatic transaction support into | ||
| 44 | Catalyst Actions, it will associate a given action with the | ||
| 45 | appropriate action class and save the DBIC::Schema model class name | ||
| 46 | for later use. | ||
| 47 | |||
| 48 | The action will be executed inside a txn_do, and a die inside that | ||
| 49 | method will cause the transaction to be rolled back, as documented in | ||
| 50 | DBIx::Class::Schema. | ||
| 51 | |||
| 52 | This method will not, on the other hand, handle that exception, since | ||
| 53 | txn_do will rethrow it. This means that this handling is not much | ||
| 54 | intrusive in the action processing flow. | ||
| 55 | |||
| 56 | =head1 AUTHORS | ||
| 57 | |||
| 58 | Daniel Ruoso <daniel@ruoso.com> | ||
| 59 | |||
| 60 | =head1 BUG REPORTS | ||
| 61 | |||
| 62 | Please submit all bugs regarding C<Catalyst::Controller::DBIC::Transaction> to | ||
| 63 | C<bug-catalyst-controller-dbic-transaction@rt.cpan.org> | ||
| 64 | |||
| 65 | =head1 LICENSE | ||
| 66 | |||
| 67 | This library is free software, you can redistribute it and/or modify | ||
| 68 | it under the same terms as Perl itself. | ||
| 69 | |||
| 70 | =cut | ||