| 1 | package PawsX::DynamoDB::DocumentClient::BatchGet; | ||||||||||||
| 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 Net::Amazon::DynamoDB::Marshaler; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | 1 | ▶ | use PawsX::DynamoDB::DocumentClient::Util qw( | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 8 | make_assert_arrayref | ||||||||||||
| 9 | make_assert_hashref | ||||||||||||
| 10 | unmarshal_attribute_map | ||||||||||||
| 11 | 1 | ); | |||||||||||
| 12 | 1 | ▶ | use PerlX::Maybe; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 13 | |||||||||||||
| 14 | 1 | my $METHOD_NAME = 'batch_get()'; | |||||||||||
| 15 | 1 | my $ASSERT_HASHREF = make_assert_hashref($METHOD_NAME); | |||||||||||
| 16 | 1 | my $ASSERT_ARRAYREF = make_assert_arrayref($METHOD_NAME); | |||||||||||
| 17 | |||||||||||||
| 18 | 5 | ▶ | sub transform_arguments { | ||||||||||
|
Subroutine
transform_arguments: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 19 | 5 | my $class = shift; | |||||||||||
| 20 | 5 | my %args = @_; | |||||||||||
| 21 | 5 | ▶ | my $force_type = delete $args{force_type} || {}; | ||||||||||
|
Condition100%2/2
delete $args{'force_type'} || {}
MC/DC100%1/1
delete $args{'force_type'} || {}
delete $args{'force_type'}
Truth table100%2/2
A
A= delete $args{'force_type'}
| |||||||||||||
| 22 | return ( | ||||||||||||
| 23 | %args, | ||||||||||||
| 24 | RequestItems => _marshall_request_items( | ||||||||||||
| 25 | $args{RequestItems}, | ||||||||||||
| 26 | 5 | $force_type | |||||||||||
| 27 | ), | ||||||||||||
| 28 | ); | ||||||||||||
| 29 | } | ||||||||||||
| 30 | |||||||||||||
| 31 | 1 | ▶ | sub transform_output { | ||||||||||
|
Subroutine
transform_output: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 32 | 1 | my ($class, $output) = @_; | |||||||||||
| 33 | 1 | my $response = $output->Responses; | |||||||||||
| 34 | return { | ||||||||||||
| 35 | 1 | responses => _unmarshall_responses($output->Responses), | |||||||||||
| 36 | unprocessed_keys => _unmarshall_unproc_keys($output->UnprocessedKeys), | ||||||||||||
| 37 | }; | ||||||||||||
| 38 | } | ||||||||||||
| 39 | |||||||||||||
| 40 | 0 | ▶ | sub run_service_command { | ||||||||||
|
Subroutine
run_service_command: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 41 | 0 | my ($class, $service, %args) = @_; | |||||||||||
| 42 | 0 | return $service->BatchGetItem(%args); | |||||||||||
| 43 | } | ||||||||||||
| 44 | |||||||||||||
| 45 | 5 | ▶ | sub _marshall_request_items { | ||||||||||
|
Subroutine
_marshall_request_items: called CC=1 SCAR=0.0
| |||||||||||||
| 46 | 5 | my ($items, $force_type) = @_; | |||||||||||
| 47 | 5 | $ASSERT_HASHREF->('RequestItems', $items); | |||||||||||
| 48 | return { | ||||||||||||
| 49 | 4 | map { $_ => _marshall_request_item($items->{$_}, $force_type->{$_}) } | |||||||||||
| 50 | keys %$items | ||||||||||||
| 51 | }; | ||||||||||||
| 52 | } | ||||||||||||
| 53 | |||||||||||||
| 54 | 5 | ▶ | sub _marshall_request_item { | ||||||||||
|
Subroutine
_marshall_request_item: called CC=4 SCAR=13.9
| |||||||||||||
| 55 | 5 | my ($item, $force_type) = @_; | |||||||||||
| 56 | 5 | my $keys = $item->{Keys}; | |||||||||||
| 57 | 5 | ▶ | $force_type ||= {}; | ||||||||||
|
Condition100%2/2
$force_type ||= {}
MC/DC100%1/1
$force_type ||= {}
$force_type
Truth table100%2/2
A
A= $force_type
| |||||||||||||
| 58 | 5 | ▶ | die "$METHOD_NAME: RequestItems entry must have Keys" unless $keys; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 59 | 4 | $ASSERT_ARRAYREF->('Keys', $keys); | |||||||||||
| 60 | $ASSERT_HASHREF->('Keys entry', $_) | ||||||||||||
| 61 | 3 | for @$keys; | |||||||||||
| 62 | return { | ||||||||||||
| 63 | %$item, | ||||||||||||
| 64 | Keys => [ | ||||||||||||
| 65 | 3 | map { dynamodb_marshal($_, force_type => $force_type) } | |||||||||||
| 66 | 2 | @{$item->{Keys}} | |||||||||||
| 67 | ], | ||||||||||||
| 68 | }; | ||||||||||||
| 69 | } | ||||||||||||
| 70 | |||||||||||||
| 71 | 1 | ▶ | sub _unmarshall_responses { | ||||||||||
|
Subroutine
_unmarshall_responses: called CC=2 SCAR=7.0
| |||||||||||||
| 72 | 1 | my ($responses) = @_; | |||||||||||
| 73 | 1 | ▶ | return undef unless $responses; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 74 | 1 | my $tables = $responses->Map; | |||||||||||
| 75 | return { | ||||||||||||
| 76 | 1 | map { $_ => _unmarshall_response_items($tables->{$_}) } | |||||||||||
| 77 | keys %$tables | ||||||||||||
| 78 | }; | ||||||||||||
| 79 | } | ||||||||||||
| 80 | |||||||||||||
| 81 | 2 | ▶ | sub _unmarshall_response_items { | ||||||||||
|
Subroutine
_unmarshall_response_items: called CC=1 SCAR=0.0
| |||||||||||||
| 82 | 2 | my ($items) = @_; | |||||||||||
| 83 | 2 | return [ map { unmarshal_attribute_map($_) } @$items ]; | |||||||||||
| 84 | } | ||||||||||||
| 85 | |||||||||||||
| 86 | 1 | ▶ | sub _unmarshall_unproc_keys { | ||||||||||
|
Subroutine
_unmarshall_unproc_keys: called CC=2 SCAR=7.0
| |||||||||||||
| 87 | 1 | my ($unprocessed) = @_; | |||||||||||
| 88 | 1 | my $tables = $unprocessed->Map; | |||||||||||
| 89 | 1 | ▶ | return undef unless %$tables; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 90 | return { | ||||||||||||
| 91 | 1 | map { $_ => _unmarshall_keys_and_attrs($tables->{$_}) } | |||||||||||
| 92 | keys %$tables | ||||||||||||
| 93 | }; | ||||||||||||
| 94 | } | ||||||||||||
| 95 | |||||||||||||
| 96 | 2 | ▶ | sub _unmarshall_keys_and_attrs { | ||||||||||
|
Subroutine
_unmarshall_keys_and_attrs: called CC=2 SCAR=6.9
| |||||||||||||
| 97 | 2 | my ($obj) = @_; | |||||||||||
| 98 | 2 | my $attr_names; | |||||||||||
| 99 | 2 | ▶ | if ($obj->ExpressionAttributeNames) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 100 | 1 | $attr_names = $obj->ExpressionAttributeNames->Map; | |||||||||||
| 101 | }; | ||||||||||||
| 102 | |||||||||||||
| 103 | return { | ||||||||||||
| 104 | maybe ConsistentRead => $obj->ConsistentRead, | ||||||||||||
| 105 | maybe ProjectionExpression => $obj->ProjectionExpression, | ||||||||||||
| 106 | maybe ExpressionAttributeNames => $attr_names, | ||||||||||||
| 107 | Keys => [ | ||||||||||||
| 108 | 2 | map { unmarshal_attribute_map($_) } @{$obj->Keys} | |||||||||||
| 109 | ], | ||||||||||||
| 110 | } | ||||||||||||
| 111 | } | ||||||||||||
| 112 | |||||||||||||
| 113 | 1 | 1; | |||||||||||
| 114 | __END__ | ||||||||||||