| 1 | package PawsX::DynamoDB::DocumentClient; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use 5.008_005; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Module::Runtime qw(require_module); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use Scalar::Util qw(blessed); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Paws; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | our $VERSION = '0.05'; | |||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 5 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=14 SCAR=27.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 5 | my ($class, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 14 | 5 | ▶ | my $region = $args{region} || $ENV{AWS_DEFAULT_REGION}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$args{'region'} || $ENV{'AWS_DEFAULT_REGION'}
MC/DC100%2/2
$args{'region'} || $ENV{'AWS_DEFAULT_REGION'}
$args{'region'}
$ENV{'AWS_DEFAULT_REGION'}
Truth table100%3/3
A || B
A= $args{'region'}B= $ENV{'AWS_DEFAULT_REGION'}
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 5 | my $paws = $args{paws}; | |||||||||||||||||||||||||||||||||||||||||
| 16 | 5 | my $dynamodb = $args{dynamodb}; | |||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | 5 | ▶ | if ($paws && !(blessed($paws) && $paws->isa('Paws'))) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
$paws and not builtin::blessed($paws) && $paws->isa("Paws")
builtin::blessed($paws) && $paws->isa('Paws')
MC/DC0%0/3
$paws and not builtin::blessed($paws) && $paws->isa("Paws")
$paws
builtin::blessed($paws)
$paws->isa('Paws')
Truth table50%2/4
A and not(B && C)
A= $pawsB= builtin::blessed($paws)C= $paws->isa('Paws')
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | die "paws must be a Paws object"; | |||||||||||||||||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | 5 | ▶ | if ($dynamodb && !(blessed($dynamodb) && $dynamodb->isa('Paws::DynamoDB'))) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
$dynamodb and not builtin::blessed($dynamodb) && $dynamodb->isa("Paws::DynamoDB")
builtin::blessed($dynamodb) && $dynamodb->isa('Paws::DynamoDB')
MC/DC0%0/3
$dynamodb and not builtin::blessed($dynamodb) && $dynamodb->isa("Paws::DynamoDB")
$dynamodb
builtin::blessed($dynamodb)
$dynamodb->isa('Paws::DynamoDB')
Truth table50%2/4
A and not(B && C)
A= $dynamodbB= builtin::blessed($dynamodb)C= $dynamodb->isa('Paws::DynamoDB')
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | die "dynamodb must be a Paws::DynamoDB object"; | |||||||||||||||||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | 5 | ▶ | if (!$region && $paws) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $region and $paws
MC/DC100%2/2
not $region and $paws
not $region
$paws
Truth table100%3/3
not(A) and B
A= not $regionB= $paws
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | 1 | $region = $paws->config->region; | |||||||||||||||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | 5 | ▶ | if (!($dynamodb || $region)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$dynamodb or $region
MC/DC100%2/2
$dynamodb or $region
$dynamodb
$region
Truth table100%3/3
A or B
A= $dynamodbB= $region
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | 1 | die "unable to determine region, and no dynamodb object provided"; | |||||||||||||||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | 4 | ▶ | if (!$paws) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | 3 | $paws = Paws->new(config => { region => $region}); | |||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | 4 | ▶ | if (!$dynamodb) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | 3 | $dynamodb = $paws->service('DynamoDB'); | |||||||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | 4 | my $self = { | |||||||||||||||||||||||||||||||||||||||||
| 43 | paws => $paws, | ||||||||||||||||||||||||||||||||||||||||||
| 44 | dynamodb => $dynamodb, | ||||||||||||||||||||||||||||||||||||||||||
| 45 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | 4 | return bless $self, $class; | |||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | sub batch_get { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
batch_get: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | my $command_class = 'PawsX::DynamoDB::DocumentClient::BatchGet'; | |||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | $self->_run_command($command_class, %args); | |||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | sub batch_write { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
batch_write: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | my $command_class = 'PawsX::DynamoDB::DocumentClient::BatchWrite'; | |||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | $self->_run_command($command_class, %args); | |||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | sub delete { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delete: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | my $command_class = 'PawsX::DynamoDB::DocumentClient::Delete'; | |||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | $self->_run_command($command_class, %args); | |||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | sub get { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | my $command_class = 'PawsX::DynamoDB::DocumentClient::Get'; | |||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | $self->_run_command($command_class, %args); | |||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | sub put { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
put: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | my $command_class = 'PawsX::DynamoDB::DocumentClient::Put'; | |||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | $self->_run_command($command_class, %args); | |||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | sub query { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
query: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | my $command_class = 'PawsX::DynamoDB::DocumentClient::Query'; | |||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | $self->_run_command($command_class, %args); | |||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | sub scan { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
scan: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | my $command_class = 'PawsX::DynamoDB::DocumentClient::Scan'; | |||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | $self->_run_command($command_class, %args); | |||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | sub update { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
update: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | my $command_class = 'PawsX::DynamoDB::DocumentClient::Update'; | |||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | $self->_run_command($command_class, %args); | |||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | sub _run_command { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_run_command: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | my ($self, $command_class, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | ▶ | my $return_paws_output = delete $args{return_paws_output} || 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
delete $args{'return_paws_output'} || 0
MC/DC0%0/1
delete $args{'return_paws_output'} || 0
delete $args{'return_paws_output'}
Truth table0%0/2
A
A= delete $args{'return_paws_output'}
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | require_module($command_class); | |||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | my $service = $self->{dynamodb}; | |||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | my %service_args = $command_class->transform_arguments(%args); | |||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | my $output = $command_class->run_service_command($service, %service_args); | |||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | return $output if $return_paws_output; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | return $command_class->transform_output($output); | |||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||
| 112 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 113 | __END__ | ||||||||||||||||||||||||||||||||||||||||||