| 1 | package WebDyne::Cloudflare::DurableObject::Context; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use 5.020; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Future::AsyncAwait; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use WebDyne::Cloudflare::DurableObject; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | our @ISA=qw(WebDyne::Cloudflare::DurableObject); | |||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | our $VERSION='0.001'; | |||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | my ($class, $scope_hr)=@_; | |||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | my $extension_hr=WebDyne::Cloudflare::DurableObject::capability($scope_hr); | |||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | ▶ | die "Context is only available inside a Durable Object\n" unless $extension_hr->{'id'}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | return bless({capability => $extension_hr->{'capability'}, id => $extension_hr->{'id'}, scope => $scope_hr}, $class); | |||||||||||||||||||||||||||||||||||||||||
| 16 | } | ||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | 0 | ▶ | sub scope { return shift()->{'scope'}; } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
scope: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | ▶ | sub storage { return shift(); } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
storage: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | 2 | ▶ | sub statement { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
statement: called CC=5 SCAR=18.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 2 | my ($sql, $attr_hr, @params)=@_; | |||||||||||||||||||||||||||||||||||||||||
| 24 | 2 | ▶ | die "Storage attributes are not supported\n" if defined($attr_hr); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 1 | ▶ | die "SQL must be non-empty text\n" unless (defined($sql)&&!ref($sql)&&length($sql)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
defined $sql and not ref $sql and length $sql
defined $sql and not ref $sql
MC/DC0%0/3
defined $sql and not ref $sql and length $sql
defined $sql
not ref $sql
length $sql
Truth table25%1/4
A and not(B) and C
A= defined $sqlB= not ref $sqlC= length $sql
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | 1 | return {sql => $sql, params => WebDyne::Cloudflare::DurableObject::encode_value(\@params)}; | |||||||||||||||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | 2 | ▶ | async sub query { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
query: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | 2 | my ($self, @args)=@_; | |||||||||||||||||||||||||||||||||||||||||
| 32 | 2 | return WebDyne::Cloudflare::DurableObject::decode_value( | |||||||||||||||||||||||||||||||||||||||||
| 33 | await $self->execute(operation => 'sql', statement => statement(@args))); | ||||||||||||||||||||||||||||||||||||||||||
| 34 | 1 | } | |||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | 1 | ▶ | async sub do { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
do: called CC=1 SCAR=0.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 38 | 1 | my ($self, @args)=@_; | |||||||||||||||||||||||||||||||||||||||||
| 39 | 1 | my $result_hr=await $self->query(@args); | |||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | return $result_hr->{'rows_written'}; | |||||||||||||||||||||||||||||||||||||||||
| 41 | 1 | } | |||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | 1 | ▶ | async sub selectrow_hashref { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
selectrow_hashref: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | 1 | my ($self, @args)=@_; | |||||||||||||||||||||||||||||||||||||||||
| 46 | 1 | my $result_hr=await $self->query(@args); | |||||||||||||||||||||||||||||||||||||||||
| 47 | 1 | return $result_hr->{'rows'}[0]; | |||||||||||||||||||||||||||||||||||||||||
| 48 | 1 | } | |||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | async sub selectall_arrayref { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
selectall_arrayref: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | my ($self, @args)=@_; | |||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | my $result_hr=await $self->query(@args); | |||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | return $result_hr->{'rows'}; | |||||||||||||||||||||||||||||||||||||||||
| 55 | 1 | } | |||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | ▶ | async sub batch { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
batch: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | my ($self, $statements_ar)=@_; | |||||||||||||||||||||||||||||||||||||||||
| 60 | die "batch requires a non-empty array of [SQL, undef, bind values...]\n" | ||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | unless ((ref($statements_ar) eq 'ARRAY')&&@{$statements_ar}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $statements_ar eq "ARRAY" and @{$statements_ar;}
MC/DC0%0/2
ref $statements_ar eq "ARRAY" and @{$statements_ar;}
ref $statements_ar eq "ARRAY"
@{$statements_ar;}
Truth table0%0/3
A and B
A= ref $statements_ar eq "ARRAY"B= @{$statements_ar;}
| |||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | my @statements; | |||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | foreach my $statement_ar (@{$statements_ar}) { | |||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | die "Invalid batch statement\n" unless (ref($statement_ar) eq 'ARRAY'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | push(@statements, statement(@{$statement_ar})); | |||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | return WebDyne::Cloudflare::DurableObject::decode_value( | |||||||||||||||||||||||||||||||||||||||||
| 68 | await $self->execute(operation => 'batch', statements => \@statements)); | ||||||||||||||||||||||||||||||||||||||||||
| 69 | 1 | } | |||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||