| 1 | package DBIx::Objects; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use warnings qw(all); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use vars qw($VERSION); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | $VERSION=0.04; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | ### | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | package DBIx::Object; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 1 | ▶ | use warnings qw(all); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | # Back-end methods | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | ▶ | sub _blank { # Default back-end for constructor | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_blank: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | # ARGS: $self, [$namespace,] @arglist | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | # $namespace - Scalar (string) - Namespace of managing package for variables | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | # @arglist - Array (string) - List of variables to be registered as methods | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | my $self=shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | ▶ | my $package= | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
UNIVERSAL::isa($_[0], __PACKAGE__) && shift() || caller
UNIVERSAL::isa($_[0], __PACKAGE__) and shift()
MC/DC0%0/3
UNIVERSAL::isa($_[0], __PACKAGE__) && shift() || caller
UNIVERSAL::isa($_[0], __PACKAGE__)
shift()
caller
Truth table0%0/5
A and B || C
A= UNIVERSAL::isa($_[0], __PACKAGE__)B= shift()C= caller
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | (UNIVERSAL::isa($_[0],__PACKAGE__) && # Looks like a descendant | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | shift) || caller; # Shift or autodetect namespace to register | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | warn "Package $package not listed in registry" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | ▶ | unless defined($self->{_REGISTRY}{$package}); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | ▶ | while (@_) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | local $_=uc(shift); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | $self->{$_}=undef; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | $self->{_REGISTRY}{_DATA}{$_}{source}=$package; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | $self->{_REGISTRY}{_DATA}{$_}{access}=1; # default to rw | |||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | $self->{_REGISTRY}{_DATA}{$_}{type}="basic"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | sub _register { # Default back-end for package registration | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_register: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | # Call immediately after being bless()ed | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | my $self=shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | my $package=caller; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | $self->{_REGISTRY}{$package}{prep}=0 unless (defined($self->{_REGISTRY}{$package})); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | return defined($self->{_REGISTRY}{$package}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | sub _unregister{# Default back-end for package de-registration | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_unregister: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | # If you wish to partially destruct an object, make sure to call this | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | # from each namespace being removed from the object | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | my $self=shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | my $package=caller; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | $self->_taint($package); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | undef $self->{_REGISTRY}{$package}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | return (!(defined($self->{_REGISTRY}{$package}))); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | sub _primary { # Sets/detects whether a namespace contains the primary key | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_primary: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | # Used internally to assure that the primary key's namespace is always | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | # in sync with the rest of the object | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | my $self=shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | my $package=(UNIVERSAL::isa($_[0],__PACKAGE__) && shift) || caller; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
UNIVERSAL::isa($_[0], __PACKAGE__) && shift() || caller
UNIVERSAL::isa($_[0], __PACKAGE__) and shift()
MC/DC0%0/3
UNIVERSAL::isa($_[0], __PACKAGE__) && shift() || caller
UNIVERSAL::isa($_[0], __PACKAGE__)
shift()
caller
Truth table0%0/5
A and B || C
A= UNIVERSAL::isa($_[0], __PACKAGE__)B= shift()C= caller
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | if ($_[0]) {$self->{_REGISTRY}{_PRIMARY}=$package;$self->_taint;} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | return ($self->{_REGISTRY}{_PRIMARY} || 0); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{'_REGISTRY'}{'_PRIMARY'} || 0
MC/DC0%0/1
$self->{'_REGISTRY'}{'_PRIMARY'} || 0
$self->{'_REGISTRY'}{'_PRIMARY'}
Truth table0%0/2
A
A= $self->{'_REGISTRY'}{'_PRIMARY'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | sub _readonly { # Sets/detects whether a data mehod is tagged read-only | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_readonly: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | # Used by AUTOLOAD to detect read-only method calls | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | my $self=shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | my $package=(UNIVERSAL::isa($_[0],__PACKAGE__) && shift) || caller; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
UNIVERSAL::isa($_[0], __PACKAGE__) && shift() || caller
UNIVERSAL::isa($_[0], __PACKAGE__) and shift()
MC/DC0%0/3
UNIVERSAL::isa($_[0], __PACKAGE__) && shift() || caller
UNIVERSAL::isa($_[0], __PACKAGE__)
shift()
caller
Truth table0%0/5
A and B || C
A= UNIVERSAL::isa($_[0], __PACKAGE__)B= shift()C= caller
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | my $var=uc(shift); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | if (@_) {local $_=shift;$self->{_REGISTRY}{_DATA}{$var}{access}=(!($_)?1:0) if (/[01]/);} #Set to "0" to catch in this check next time | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | return (!($self->{_REGISTRY}{_DATA}{$var}{access}) || | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | $self->{_REGISTRY}{_DATA}{$var}{source} eq $self->_primary); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
!$self->{'_REGISTRY'}{'_DATA'}{$var}{'access'} || $self->{'_REGISTRY'}{'_DATA'}{$var}{'source'} eq $self->_primary
MC/DC0%0/2
!$self->{'_REGISTRY'}{'_DATA'}{$var}{'access'} || $self->{'_REGISTRY'}{'_DATA'}{$var}{'source'} eq $self->_primary
!$self->{'_REGISTRY'}{'_DATA'}{$var}{'access'}
$self->{'_REGISTRY'}{'_DATA'}{$var}{'source'} eq $self->_primary
Truth table0%0/3
not(A) || B
A= !$self->{'_REGISTRY'}{'_DATA'}{$var}{'access'}B= $self->{'_REGISTRY'}{'_DATA'}{$var}{'source'} eq $self->_primary
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | sub _validate { # Marks a namespace as tied to the back-end database | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_validate: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | # Intended to be called on first refresh - Paired with _taint | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | my $self=shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | my $package=shift || caller; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
shift() || caller
MC/DC0%0/2
shift() || caller
shift()
caller
Truth table0%0/3
A || B
A= shift()B= caller
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | (my @vars=$self->_vars($package)) || return $self; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | foreach my $var (@vars) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | ▶ | if ($self->_isobject($var)) { # Reset embedded object information (only if needed) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | ▶ | unless ($self->{var} && ($self->{_REGISTRY}{_DATA}{$var}{data} eq $self->{$var})) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"var"} and $self->{"_REGISTRY"}{"_DATA"}{$var}{"data"} eq $self->{$var}
MC/DC0%0/2
$self->{"var"} and $self->{"_REGISTRY"}{"_DATA"}{$var}{"data"} eq $self->{$var}
$self->{"var"}
$self->{"_REGISTRY"}{"_DATA"}{$var}{"data"} eq $self->{$var}
Truth table0%0/3
A and B
A= $self->{"var"}B= $self->{"_REGISTRY"}{"_DATA"}{$var}{"data"} eq $self->{$var}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | $self->{_REGISTRY}{_DATA}{$var}{data}=$self->{$var}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | $self->{_REGISTRY}{_DATA}{$var}{prep}=0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | $self->{$var}=undef; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | $self->{_REGISTRY}{$package}{prep}=1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | $self->{_REGISTRY}{ref($self)}{prep}=1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | $self->_clean($package); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | ▶ | sub _taint { # Marks a namespace as untied from the back-end database | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_taint: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | # Intended to be called on destruction only | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | my $self=shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | ▶ | my $package=shift || caller; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
shift() || caller
MC/DC0%0/2
shift() || caller
shift()
caller
Truth table0%0/3
A || B
A= shift()B= caller
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | $self->_dirty($package); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | (my @vars=$self->_vars($package)) || return $self; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | foreach my $var (@vars) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | if ($self->_isobject($var)) { # Reset embedded object information (only if needed) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | $self->{_REGISTRY}{_DATA}{$var}{prep}=0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | $self->{$var}=undef; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | $self->{_REGISTRY}{$package}{prep}=0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | sub _clean { # Marks a namespace as in-sync with the back-end database | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_clean: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | # Intended to be called on all calls to add(), refresh() and update() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | my $self=shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | my $package=shift || caller; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
shift() || caller
MC/DC0%0/2
shift() || caller
shift()
caller
Truth table0%0/3
A || B
A= shift()B= caller
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | $self->{_REGISTRY}{$package}{dirty}=0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | ▶ | sub _dirty { # Marks a namespace as out-of-sync with the back-end databse | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_dirty: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | # Intended to be called upon a write-access call to a class-method | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | my $self=shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | ▶ | my $package=shift || caller; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
shift() || caller
MC/DC0%0/2
shift() || caller
shift()
caller
Truth table0%0/3
A || B
A= shift()B= caller
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | $self->{_REGISTRY}{$package}{dirty}=1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | ▶ | sub _vars { # Returns a list of variables registered to a specific namespace | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_vars: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | # Used internally by default _refresh() and update() methods | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | my $self=shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | ▶ | my $package=shift || caller; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
shift() || caller
MC/DC0%0/2
shift() || caller
shift()
caller
Truth table0%0/3
A || B
A= shift()B= caller
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | my @vars = (); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | my @keys = keys(%{$self->{_REGISTRY}{_DATA}}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | foreach my $var(@keys) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | ▶ | push @vars,$var if ($self->{_REGISTRY}{_DATA}{$var}{source} eq $package); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | return @vars; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | sub _refresh { # Default back-end for refresh | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_refresh: not called CC=7 SCAR=37.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | # Inherited classes should implement a custom _refresh() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | # Alternatively, the default _refresh may be used if a valid DBI connection | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | # is set using $__PACKAGE__::dbh and the table is set to $__PACKAGE__::table | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | my $self=shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | ▶ | my $package=(UNIVERSAL::isa($_[0],__PACKAGE__) && shift) || ref($self); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
UNIVERSAL::isa($_[0], __PACKAGE__) && shift() || ref $self
UNIVERSAL::isa($_[0], __PACKAGE__) and shift()
MC/DC0%0/3
UNIVERSAL::isa($_[0], __PACKAGE__) && shift() || ref $self
UNIVERSAL::isa($_[0], __PACKAGE__)
shift()
ref $self
Truth table0%0/5
A and B || C
A= UNIVERSAL::isa($_[0], __PACKAGE__)B= shift()C= ref $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | my @vars=$self->_vars($package) || return $self; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->_vars($package) || (return $self)
MC/DC0%0/1
$self->_vars($package) || (return $self)
$self->_vars($package)
Truth table0%0/2
A
A= $self->_vars($package)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | my $sth; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | no strict 'vars'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | eval "\$sth=\$dbh->prepare_cached('SELECT \@vars FROM \$table WHERE (ID=?)');"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | ▶ | $sth->execute(@_) or return $self->blank; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | ▶ | if ($sth->rows!=1) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | $self->blank; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | my $res=$sth->fetchrow_hashref; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | foreach my $var (@vars) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | $self->{$var}=$res->{$var}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | $self->_validate; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | $sth->finish; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | ▶ | sub AUTOLOAD { # Default method call handler | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AUTOLOAD: not called CC=15 SCAR=53.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | # Current support: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | # * Read/Write registered methods from internal hash | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | my $param; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | my $package; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | ▶ | no strict 'vars'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | $AUTOLOAD=~s/(.*):://; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | $package=$1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | $param=$AUTOLOAD; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | ▶ | if (UNIVERSAL::isa($_[0],__PACKAGE__)) { # Method call of a sub-class | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | my $self=shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | if ($self->{_REGISTRY}{_DATA}{uc($param)}) { # Acceptable function call | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | my $source=$self->{_REGISTRY}{_DATA}{uc($param)}{source}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | ▶ | if (!($self->valid($source))) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | $self->refresh($source); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | # SET access | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | ▶ | if ((@_) && !($self->_readonly($source,$param))) { # Update rewriteable request | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@_ and not $self->_readonly($source, $param)
MC/DC0%0/2
@_ and not $self->_readonly($source, $param)
@_
not $self->_readonly($source, $param)
Truth table0%0/3
A and not(B)
A= @_B= not $self->_readonly($source, $param)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | ▶ | if ($self->_isbasic($param)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | $self->{uc($param)}=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | $self->_taint; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | } elsif ($self->_isobject($param)) { # Object SET | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | ▶ | unless ($self->_isobjarray($param)) { # No SET allowed on arrays | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | my ($temp,$pid)=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | ▶ | if (ref($temp) eq $self->{_REGISTRY}{_DATA}{uc($param)}{class}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | # TODO: see if temp->isa($self->{_REGISTRY}{_DATA}{uc($param)}{class}) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | $pid=$temp->id; #Retrieve ID from internal object | |||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | $pid=$temp; #Assume ID is specified if not compatible object | |||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | $self->{_REGISTRY}{_DATA}{uc($param)}{data}=$pid; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | $self->_taint; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | } # GET access | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | ▶ | if ($self->_isobject($param)) { # Prepare object | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | ▶ | return (wantarray?undef:0) unless $self->_o_prep($param); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | ▶ | if ($self->_isobjarray($param)) { # Object array returns special values | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | return (wantarray?@{$self->{uc($param)}}:$self->{_REGISTRY}{_DATA}{uc($param)}{prep}); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | return $self->{uc($param)}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | ▶ | sub new { # Default constructor | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | # Do not overload this unless you're SURE you know what you're doing | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | my $self={ }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | my $proto=shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | my $class=ref($proto) || $proto; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $proto || $proto
MC/DC0%0/2
ref $proto || $proto
ref $proto
$proto
Truth table0%0/3
A || B
A= ref $protoB= $proto
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | bless $self,$class; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | eval "foreach \$_ (\@".$class."::ISA) {eval \$_.\"::blank(\\\$self);\";}"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | $self->_register; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | $self->blank(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | ▶ | eval ($self->_primary."::_refresh(\$self,'".$self->_primary."',@_);") if ($self->_primary); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | $self->_refresh(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | ▶ | sub clean { # Returns true if namepace is in-sync with back-end database | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clean: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | # Be sure to check for valid()ity BEFORE using this | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | my $self=shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | ▶ | my $package=shift || caller; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
shift() || caller
MC/DC0%0/2
shift() || caller
shift()
caller
Truth table0%0/3
A || B
A= shift()B= caller
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | return !($self->{_REGISTRY}{$package}{dirty}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | ▶ | sub valid { # Returns true if namespace is tied and in-sync with back-end database | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
valid: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | my $self=shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | ▶ | my $package=shift || ref($self); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
shift() || ref $self
MC/DC0%0/2
shift() || ref $self
shift()
ref $self
Truth table0%0/3
A || B
A= shift()B= ref $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | ▶ | if ($self->_primary) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | {return ($self->{_REGISTRY}{$self->_primary}{prep} && | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | $self->clean($self->_primary) && | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | $self->{_REGISTRY}{$package}{prep} && | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | ▶ | $self->clean($package))} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/9
$self->{'_REGISTRY'}{$self->_primary}{'prep'} && $self->clean($self->_primary) && $self->{'_REGISTRY'}{$package}{'prep'} && $self->clean($package)
$self->{"_REGISTRY"}{$self->_primary}{"prep"} and $self->clean($self->_primary) and $self->{"_REGISTRY"}{$package}{"prep"}
$self->{"_REGISTRY"}{$self->_primary}{"prep"} and $self->clean($self->_primary)
MC/DC0%0/4
$self->{'_REGISTRY'}{$self->_primary}{'prep'} && $self->clean($self->_primary) && $self->{'_REGISTRY'}{$package}{'prep'} && $self->clean($package)
$self->{"_REGISTRY"}{$self->_primary}{"prep"}
$self->clean($self->_primary)
$self->{"_REGISTRY"}{$package}{"prep"}
$self->clean($package)
Truth table0%0/5
A and B and C && D
A= $self->{"_REGISTRY"}{$self->_primary}{"prep"}B= $self->clean($self->_primary)C= $self->{"_REGISTRY"}{$package}{"prep"}D= $self->clean($package)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | else {return $self->{_REGISTRY}{$package}{prep} && | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | ▶ | $self->clean($package)}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{'_REGISTRY'}{$package}{'prep'} && $self->clean($package)
MC/DC0%0/2
$self->{'_REGISTRY'}{$package}{'prep'} && $self->clean($package)
$self->{'_REGISTRY'}{$package}{'prep'}
$self->clean($package)
Truth table0%0/3
A && B
A= $self->{'_REGISTRY'}{$package}{'prep'}B= $self->clean($package)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | ▶ | sub blank { # Default (abstract) blank method - used by the default constructor | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
blank: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | # This should be overridden by any inherited class that's meant to be useful | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | # A typical blank() method should look like: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | # sub blank { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | # my $self=shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | # $self->_register; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | # $self->_blank("FOO", "BAR", ... , "LAST"); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | # } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | $_[0]->_register; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | ▶ | sub refresh { # Default front-end for refresh | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
refresh: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | my $self=shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | ▶ | my $package=shift || ref($self); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
shift() || ref $self
MC/DC0%0/2
shift() || ref $self
shift()
ref $self
Truth table0%0/3
A || B
A= shift()B= ref $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | $self->_taint($package); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | eval $package."::_refresh(\$self,".$self->id.");"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | return $self->valid; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | ▶ | sub id { # Default id method - must be explicitly so that it can be overloaded | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
id: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | # when needed for refresh, but not be dependant on the object being valid | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | my $self=shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | # Set access | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | ▶ | if ((@_) && !($self->_readonly("id"))) { # Update rewriteable request | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@_ and not $self->_readonly("id")
MC/DC0%0/2
@_ and not $self->_readonly("id")
@_
not $self->_readonly("id")
Truth table0%0/3
A and not(B)
A= @_B= not $self->_readonly("id")
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | $self->{ID}=@_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | $self->_taint; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | return $self->{ID}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | ▶ | sub _isbasic { # Returns true if access method marked as basic (default) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_isbasic: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | my $self=shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | my $var=uc(shift); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | return ($self->{_REGISTRY}{_DATA}{$var}{type} eq "basic"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | ▶ | sub _isobject { # Returns true if access method marked as embedded object | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_isobject: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | my $self=shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | my $var=uc(shift); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | return ($self->{_REGISTRY}{_DATA}{$var}{type} eq "object"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | ▶ | sub _isobjarray { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_isobjarray: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | my $self=shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | my $var=uc(shift); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | ▶ | return ($self->_isobject($var) && $self->{_REGISTRY}{_DATA}{$var}{array}); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->_isobject($var) && $self->{'_REGISTRY'}{'_DATA'}{$var}{'array'}
MC/DC0%0/2
$self->_isobject($var) && $self->{'_REGISTRY'}{'_DATA'}{$var}{'array'}
$self->_isobject($var)
$self->{'_REGISTRY'}{'_DATA'}{$var}{'array'}
Truth table0%0/3
A && B
A= $self->_isobject($var)B= $self->{'_REGISTRY'}{'_DATA'}{$var}{'array'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | ▶ | sub _object { # Marks an access member as an object (call in blank) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_object: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | my $self=shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | my $var=uc(shift); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | ▶ | my $package=(UNIVERSAL::isa($_[0],__PACKAGE__) && shift) || ref($self); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
UNIVERSAL::isa($_[0], __PACKAGE__) && shift() || ref $self
UNIVERSAL::isa($_[0], __PACKAGE__) and shift()
MC/DC0%0/3
UNIVERSAL::isa($_[0], __PACKAGE__) && shift() || ref $self
UNIVERSAL::isa($_[0], __PACKAGE__)
shift()
ref $self
Truth table0%0/5
A and B || C
A= UNIVERSAL::isa($_[0], __PACKAGE__)B= shift()C= ref $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | $self->{_REGISTRY}{_DATA}{$var}{prep}=0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | $self->{_REGISTRY}{_DATA}{$var}{class}=$package; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | ▶ | $self->{_REGISTRY}{_DATA}{$var}{data}=$self->{$var} || undef; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{$var} || undef
MC/DC0%0/1
$self->{$var} || undef
$self->{$var}
Truth table0%0/2
A
A= $self->{$var}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | $self->{_REGISTRY}{_DATA}{$var}{array}=0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | $self->{_REGISTRY}{_DATA}{$var}{type}="object"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | $self->{$var}=undef; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | ▶ | sub _objarray { # Marks an access member as an array of objects (call in blank) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_objarray: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | my $self=shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | my $var=uc(shift); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | ▶ | my $package=(UNIVERSAL::isa($_[0],__PACKAGE__) && shift) || ref($self); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
UNIVERSAL::isa($_[0], __PACKAGE__) && shift() || ref $self
UNIVERSAL::isa($_[0], __PACKAGE__) and shift()
MC/DC0%0/3
UNIVERSAL::isa($_[0], __PACKAGE__) && shift() || ref $self
UNIVERSAL::isa($_[0], __PACKAGE__)
shift()
ref $self
Truth table0%0/5
A and B || C
A= UNIVERSAL::isa($_[0], __PACKAGE__)B= shift()C= ref $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | $self->_object($var,$package); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | $self->_readonly($var,1); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | $self->{_REGISTRY}{_DATA}{$var}{array}=1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | # This (objarray) won't be fully implemented until I can figure out how the heck | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | # to set the data source as an array - it probably has to be dealt with by | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | # end-module's refresh ($self->{$var}=@arrayofdata;) [UPDATE VALIDATE TO DEAL WITH THIS]... | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | ▶ | sub _o_prep { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_o_prep: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | my $self=shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | my $var=uc(shift); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | my $class=$self->{_REGISTRY}{_DATA}{$var}{class}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | my $source=$self->{_REGISTRY}{_DATA}{$var}{source}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | ▶ | return 0 unless $self->valid($source); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | return $self->{_REGISTRY}{_DATA}{$var}{prep} if | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | ▶ | $self->{_REGISTRY}{_DATA}{$var}{prep}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | ▶ | if ($self->_isobjarray($var)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | ▶ | for (my $i=0;$i<=$#{$self->{_REGISTRY}{_DATA}{$var}{data}};$i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | $self->{$var}[$i]=$class->new($self->{_REGISTRY}{_DATA}{$var}{data}[$i]); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | $self->{_REGISTRY}{_DATA}{$var}{prep}=$#{$self->{_REGISTRY}{_DATA}{$var}{data}}+1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | ▶ | $self->{_REGISTRY}{_DATA}{$var}{prep}=(($self->{$var}=$class->new($self->{_REGISTRY}{_DATA}{$var}{data}))?1:0); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | return $self->{_REGISTRY}{_DATA}{$var}{prep}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | # TODO: Update updates recursively (into embedded objects) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | # UpdateNR updates non-0recursively (data ghets lost) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | # DOCUMENT: _validate also initializes objects by setting internal DATA value and clearing external value | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | package DBIx::Object::DBI; #Shortcut functions for DBI-based backend | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 1 | our @ISA=qw(DBIx::Object); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | ▶ | sub blank { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
blank: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | $_[0]->_register; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | ▶ | sub _dbidbh { # Sets/returns the DBI connection to use | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_dbidbh: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | my $self=shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | ▶ | my $package=(UNIVERSAL::isa($_[0],__PACKAGE__) && shift) || caller; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
UNIVERSAL::isa($_[0], __PACKAGE__) && shift() || caller
UNIVERSAL::isa($_[0], __PACKAGE__) and shift()
MC/DC0%0/3
UNIVERSAL::isa($_[0], __PACKAGE__) && shift() || caller
UNIVERSAL::isa($_[0], __PACKAGE__)
shift()
caller
Truth table0%0/5
A and B || C
A= UNIVERSAL::isa($_[0], __PACKAGE__)B= shift()C= caller
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | ▶ | if($_[0]) {$self->{_REGISTRY}{$package}{DBI}{dbh}=$_[0];} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | return $self->{_REGISTRY}{$package}{DBI}{dbh}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | ▶ | sub _dbirefresh { # Sets/returns the SQL statement to run on refresh calls | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_dbirefresh: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | my $self=shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | ▶ | my $package=(UNIVERSAL::isa($_[0],__PACKAGE__) && shift) || caller; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
UNIVERSAL::isa($_[0], __PACKAGE__) && shift() || caller
UNIVERSAL::isa($_[0], __PACKAGE__) and shift()
MC/DC0%0/3
UNIVERSAL::isa($_[0], __PACKAGE__) && shift() || caller
UNIVERSAL::isa($_[0], __PACKAGE__)
shift()
caller
Truth table0%0/5
A and B || C
A= UNIVERSAL::isa($_[0], __PACKAGE__)B= shift()C= caller
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | ▶ | if($_[0]) {$self->{_REGISTRY}{$package}{DBI}{refresh}=$_[0];} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | return $self->{_REGISTRY}{$package}{DBI}{refresh}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | ▶ | sub _refresh { # Default back-end for DBI refresh | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_refresh: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | # Inherited classes may implement a custom _refresh() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | my $self=shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | ▶ | my $package=(UNIVERSAL::isa($_[0],__PACKAGE__) && shift) || ref($self); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
UNIVERSAL::isa($_[0], __PACKAGE__) && shift() || ref $self
UNIVERSAL::isa($_[0], __PACKAGE__) and shift()
MC/DC0%0/3
UNIVERSAL::isa($_[0], __PACKAGE__) && shift() || ref $self
UNIVERSAL::isa($_[0], __PACKAGE__)
shift()
ref $self
Truth table0%0/5
A and B || C
A= UNIVERSAL::isa($_[0], __PACKAGE__)B= shift()C= ref $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | my $sth=$self->{_REGISTRY}{$package}{DBI}{dbh}->prepare_cached($self->{_REGISTRY}{$package}{DBI}{refresh}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | ▶ | $sth->execute(@_) or return $self->blank; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | ▶ | if ($sth->rows!=1) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | $self->blank; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | my $res=$sth->fetchrow_hashref; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | foreach my $key (keys %{$res}) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | $self->{uc($key)}=$res->{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | $self->_validate($package); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | $sth->finish; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||