| 1 | package Yote::YapiServer::BaseObj; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use base 'Yote::SQLObjectStore::SQLite::Obj', 'Yote::SQLObjectStore::MariaDB::Obj'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | #---------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 8 | # Class data accessors — look up %HASH in the calling class | ||||||||||||||||||||||||||||||||||||||||||
| 9 | # Named to avoid colliding with get_foo/set_foo instance accessors | ||||||||||||||||||||||||||||||||||||||||||
| 10 | #---------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | sub field_access { | ||||||||||||||||||||||||||||||||||||||||||
| 13 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
field_access: not called CC=2 SCAR=12.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 0 | ▶ | my $class = ref($self) || $self; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table0%0/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 2 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 0 | return \%{"${class}::FIELD_ACCESS"}; | |||||||||||||||||||||||||||||||||||||||||
| 17 | } | ||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | sub method_defs { | ||||||||||||||||||||||||||||||||||||||||||
| 20 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
method_defs: not called CC=2 SCAR=12.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | ▶ | my $class = ref($self) || $self; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table0%0/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 2 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | return \%{"${class}::METHODS"}; | |||||||||||||||||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | #---------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 27 | # Client class name — strips Yote::YapiServer:: prefix | ||||||||||||||||||||||||||||||||||||||||||
| 28 | #---------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | sub _client_class_name { | ||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_client_class_name: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | ▶ | my $class = ref($self) || $self; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table0%0/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | $class =~ s/^Yote::YapiServer::App:://; | |||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | $class =~ s/^Yote::YapiServer:://; | |||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | return $class; | |||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | #---------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 39 | # Default serialization — filters fields by %FIELD_ACCESS rules | ||||||||||||||||||||||||||||||||||||||||||
| 40 | #---------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | sub to_client_hash { | ||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | my ($self, $session, $viewer) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
to_client_hash: not called CC=12 SCAR=50.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | my %result; | |||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | my $field_access = $self->field_access; | |||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | my $cols = $self->cols; | |||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | my $owner = eval { $self->get_owner }; | |||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | ▶ | my $is_owner = $viewer && $owner && $owner->id eq $viewer->id; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$viewer && $owner && $owner->id eq $viewer->id
$viewer and $owner
MC/DC0%0/3
$viewer && $owner && $owner->id eq $viewer->id
$viewer
$owner
$owner->id eq $viewer->id
Truth table0%0/4
A and B && C
A= $viewerB= $ownerC= $owner->id eq $viewer->id
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | my $is_admin = $viewer && $viewer->get_is_admin; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$viewer && $viewer->get_is_admin
MC/DC0%0/2
$viewer && $viewer->get_is_admin
$viewer
$viewer->get_is_admin
Truth table0%0/3
A && B
A= $viewerB= $viewer->get_is_admin
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | for my $field (keys %$field_access) { | |||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | my $rule = $field_access->{$field}; | |||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | next if $rule->{never}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | next if $rule->{owner_only} && !$is_owner && !$is_admin; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$rule->{"owner_only"} and not $is_owner and not $is_admin
$rule->{"owner_only"} and not $is_owner
MC/DC0%0/3
$rule->{"owner_only"} and not $is_owner and not $is_admin
$rule->{"owner_only"}
not $is_owner
not $is_admin
Truth table0%0/4
A and not(B) and not(C)
A= $rule->{"owner_only"}B= not $is_ownerC= not $is_admin
| |||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | ▶ | next if $rule->{admin_only} && !$is_admin; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$rule->{"admin_only"} and not $is_admin
MC/DC0%0/2
$rule->{"admin_only"} and not $is_admin
$rule->{"admin_only"}
not $is_admin
Truth table0%0/3
A and not(B)
A= $rule->{"admin_only"}B= not $is_admin
| |||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | # Use get() directly — AUTOLOAD-generated getters aren't seen by can() | ||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | next unless exists $cols->{$field}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | $result{$field} = $self->get($field); | |||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | return \%result; | |||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | __END__ | ||||||||||||||||||||||||||||||||||||||||||