blib/lib/Pinto/Role/Transactional.pm

filter: Statementstmt 100% 24 / 24 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod n/a totaltotal 100% 31 / 31 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« blib/lib/Pinto/Role/Plated.pm ↑ Summary blib/lib/Pinto/Schema/Result/Ancestry.pm »
1 # ABSTRACT: Role for actions that are transactional
2  
3 package Pinto::Role::Transactional;
4  
5 63 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 63 ▶use MooseX::MarkAsMethods ( autoclean => 1 );
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 63 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 63 ▶use Pinto::Util qw(throw);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 #------------------------------------------------------------------------------
13  
14 63 our $VERSION = '0.14'; # VERSION
15  
16 #------------------------------------------------------------------------------
17  
18 63 requires qw( execute repo );
19  
20 #------------------------------------------------------------------------------
21  
22 107 ▶around execute => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
23 107 my ( $orig, $self, @args ) = @_;
24  
25 107 $self->repo->txn_begin;
26  
27 107 ▶ my $result = try { $self->$orig(@args); $self->repo->txn_commit }
Subroutine __ANON__: called CC=1 SCAR=0.0
28 107 ▶ catch { $self->repo->txn_rollback; throw $_ };
Subroutine __ANON__: called CC=1 SCAR=0.0
29  
30 99 return $self->result;
31 63 };
32  
33 #------------------------------------------------------------------------------
34 63 1;
35  
36 __END__
« blib/lib/Pinto/Role/Plated.pm ↑ Summary blib/lib/Pinto/Schema/Result/Ancestry.pm »