blib/lib/Async/Redis/Transaction.pm

filter: Statementstmt 41.9% 13 / 31 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 44.4% 4 / 9 Podpod 66.6% 2 / 3 totaltotal 42.2% 19 / 45 CC 2 SCAR 8.8
CC
2
Cov
39%
AUTOLOAD
6.0
new
2.0
_queue_command
2.0
CRAP 2.4
« blib/lib/Async/Redis/Commands.pm ↑ Summary script/generate-commands »
1 package Async::Redis::Transaction;
2  
3 91 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 91 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 91 ▶use 5.018;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 91 ▶use Future::AsyncAwait;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
10 0 my ($class, %args) = @_;
11 return bless {
12 redis => $args{redis},
13 0 commands => [],
14 }, $class;
15 }
16  
17 # Queue a command for execution in the transaction
18 # Returns a placeholder (the actual result comes from EXEC)
19 0 ▶sub _queue_command {
Subroutine _queue_command: not called CC=1 SCAR=6.9
20 0 my ($self, $cmd, @args) = @_;
21 0 push @{$self->{commands}}, [$cmd, @args];
22 0 return scalar(@{$self->{commands}}) - 1; # index of this command
23 }
24  
25 # Generate AUTOLOAD to capture any command call
26 91 our $AUTOLOAD;
27  
28 0 ▶sub AUTOLOAD {
Subroutine AUTOLOAD: not called CC=2 SCAR=17.9
29 0 my $self = shift;
30 0 my $cmd = $AUTOLOAD;
31 0 $cmd =~ s/.*:://;
32 0 ▶ return if $cmd eq 'DESTROY';
Branch: 1 branch
BranchTrueFalseTotal
if $cmd eq "DESTROY" 0 0 0
33  
34 # Queue the command
35 0 $self->_queue_command(uc($cmd), @_);
36 0 return; # Transaction commands don't return Futures individually
37 }
38  
39 # Allow explicit command() calls too
40 0 ▶sub command {
Subroutine command: not called CC=1 SCAR=6.9
Pod documented
41 0 my ($self, $cmd, @args) = @_;
42 0 $self->_queue_command($cmd, @args);
43 0 return;
44 }
45  
46 0 ▶sub commands { @{shift->{commands}} }
Subroutine commands: not called CC=1 SCAR=6.9
Pod documented
47  
48 91 1;
49  
50 __END__
« blib/lib/Async/Redis/Commands.pm ↑ Summary script/generate-commands »