| 1 | # $Id: Roles.pm,v 1.18 2006/01/30 10:58:51 dk Exp $ | ||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||
| 3 | package DBIx::Roles; | ||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use DBI; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Scalar::Util qw(weaken); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use vars qw($VERSION %loaded_packages $DBI_connect %DBI_select_methods $debug $ExportDepth); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||
| 10 | 1 | $VERSION = '1.04'; | |||||||||||||||||||||||||||||||
| 11 | 1 | $ExportDepth = 0; | |||||||||||||||||||||||||||||||
| 12 | 1 | $DBI_connect = \&DBI::connect; | |||||||||||||||||||||||||||||||
| 13 | 1 | %DBI_select_methods = map { $_ => 1 } qw( | |||||||||||||||||||||||||||||||
| 14 | selectrow_array | ||||||||||||||||||||||||||||||||
| 15 | selectrow_arrayref | ||||||||||||||||||||||||||||||||
| 16 | selectrow_hashref | ||||||||||||||||||||||||||||||||
| 17 | selectall_arrayref | ||||||||||||||||||||||||||||||||
| 18 | selectall_hashref | ||||||||||||||||||||||||||||||||
| 19 | selectcol_arrayref | ||||||||||||||||||||||||||||||||
| 20 | ); | ||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||
| 22 | sub import | ||||||||||||||||||||||||||||||||
| 23 | 5 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
import: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 24 | 5 | shift; | |||||||||||||||||||||||||||||||
| 25 | 5 | ▶ | return unless @_; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||
| 27 | # if given list of imports, override DBI->connect() with it | ||||||||||||||||||||||||||||||||
| 28 | 1 | my $callpkg = caller($ExportDepth); | |||||||||||||||||||||||||||||||
| 29 | 1 | ▶ | no strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 30 | 1 | *{$callpkg."::DBIx_ROLES"}=[@_]; | |||||||||||||||||||||||||||||||
| 31 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 32 | 1 | ▶ | local $SIG{__WARN__} = sub {}; | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 33 | 1 | *DBI::connect = \&__DBI_import_connect; | |||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||
| 36 | # called instead of DBI-> connect | ||||||||||||||||||||||||||||||||
| 37 | sub __DBI_import_connect | ||||||||||||||||||||||||||||||||
| 38 | 4 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
__DBI_import_connect: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 39 | 4 | shift; | |||||||||||||||||||||||||||||||
| 40 | 4 | my $callpkg = caller(0); | |||||||||||||||||||||||||||||||
| 41 | 1 | ▶ | no strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 42 | 4 | my @packages = @{$callpkg."::DBIx_ROLES"}; | |||||||||||||||||||||||||||||||
| 43 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 44 | 4 | ▶ | if ( @packages) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 45 | 3 | return DBIx::Roles-> new( @packages)-> connect( @_); | |||||||||||||||||||||||||||||||
| 46 | } else { | ||||||||||||||||||||||||||||||||
| 47 | 1 | return $DBI_connect->( 'DBI', @_); | |||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||
| 51 | # prepare new instance, do not connect to DB | ||||||||||||||||||||||||||||||||
| 52 | sub new | ||||||||||||||||||||||||||||||||
| 53 | 5 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=12 SCAR=24.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 54 | 5 | my ( $class, @packages) = @_; | |||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||
| 56 | # load the necessary packages | ||||||||||||||||||||||||||||||||
| 57 | 5 | for my $p ( @packages) { | |||||||||||||||||||||||||||||||
| 58 | 25 | ▶ | $p = "DBIx::Roles::$p" unless $p =~ /:/; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 59 | 25 | ▶ | next if exists $loaded_packages{$p}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 60 | 1 | ▶ | eval "use $p;"; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 61 | 8 | ▶ | die $@ if $@; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 62 | 8 | $loaded_packages{$p} = 1; | |||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||
| 64 | 5 | push @packages, 'DBIx::Roles::Default'; | |||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||
| 66 | ## create the object: | ||||||||||||||||||||||||||||||||
| 67 | # internal data instance | ||||||||||||||||||||||||||||||||
| 68 | my $instance = { | ||||||||||||||||||||||||||||||||
| 69 | dbh => undef, # DBI handle | ||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||
| 71 | packages=> \@packages, # array of DBIx::Roles::* packages to use | ||||||||||||||||||||||||||||||||
| 72 | private => { # packages' private data - all separated | ||||||||||||||||||||||||||||||||
| 73 | 5 | map { $_ => undef } @packages | |||||||||||||||||||||||||||||||
| 74 | }, | ||||||||||||||||||||||||||||||||
| 75 | defaults=> {}, # default values and source packages for attributes | ||||||||||||||||||||||||||||||||
| 76 | disabled=> {}, # dynamically disabled packages | ||||||||||||||||||||||||||||||||
| 77 | attr => {}, # packages' public data - all mixed, and | ||||||||||||||||||||||||||||||||
| 78 | vmt => {}, # packages' public methods - also all mixed | ||||||||||||||||||||||||||||||||
| 79 | # name clashes in public and vmt will be explicitly fatal | ||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||
| 81 | loops => [], | ||||||||||||||||||||||||||||||||
| 82 | }; | ||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||
| 84 | # populate package info | ||||||||||||||||||||||||||||||||
| 85 | 5 | for my $p ( @packages) { | |||||||||||||||||||||||||||||||
| 86 | 30 | my $ref = $p->can('initialize'); | |||||||||||||||||||||||||||||||
| 87 | 30 | ▶ | next unless $ref; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 88 | 19 | my ( $storage, $data, @vmt) = $ref->( $instance); | |||||||||||||||||||||||||||||||
| 89 | 19 | $instance-> {private}-> {$p} = $storage; | |||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||
| 91 | # store default data | ||||||||||||||||||||||||||||||||
| 92 | 19 | ▶ | if ( $data) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 93 | 13 | my $dst = $instance->{attr}; | |||||||||||||||||||||||||||||||
| 94 | 13 | my $def = $instance->{defaults}; | |||||||||||||||||||||||||||||||
| 95 | 13 | ▶ | while ( my ( $key, $value) = each %$data) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 96 | die | ||||||||||||||||||||||||||||||||
| 97 | "Fatal: package '$p' defines attribute '$key' ". | ||||||||||||||||||||||||||||||||
| 98 | "that conflicts with package '$def->{$key}->[0]'" | ||||||||||||||||||||||||||||||||
| 99 | 40 | ▶ | if exists $dst->{$key}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 100 | 40 | $def->{$key} = [$p, $value]; | |||||||||||||||||||||||||||||||
| 101 | 40 | $dst->{$key} = $value; | |||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||
| 105 | # store public methods | ||||||||||||||||||||||||||||||||
| 106 | 19 | my $dst = $instance->{vmt}; | |||||||||||||||||||||||||||||||
| 107 | 19 | for my $key ( @vmt) { | |||||||||||||||||||||||||||||||
| 108 | die | ||||||||||||||||||||||||||||||||
| 109 | "Fatal: package '$p' defines method '$key' ". | ||||||||||||||||||||||||||||||||
| 110 | "that conflicts with package '$dst->{$key}'" | ||||||||||||||||||||||||||||||||
| 111 | 18 | ▶ | if exists $dst->{$key}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 112 | 18 | $dst->{$key} = $p; | |||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||
| 115 | # DBIx::Roles::Instance provides API for the packages | ||||||||||||||||||||||||||||||||
| 116 | 5 | bless $instance, 'DBIx::Roles::Instance'; | |||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||
| 118 | # DBI attributes | ||||||||||||||||||||||||||||||||
| 119 | 5 | my $self = {}; | |||||||||||||||||||||||||||||||
| 120 | 5 | tie %{$self}, 'DBIx::Roles::Instance', $instance; | |||||||||||||||||||||||||||||||
| 121 | 5 | bless $self, $class; | |||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||
| 123 | # use this trick for cheap self-referencing ( otherwise the object is never destroyed ) | ||||||||||||||||||||||||||||||||
| 124 | 5 | $instance->{self} = $self; | |||||||||||||||||||||||||||||||
| 125 | 5 | weaken( $instance->{self}); | |||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||
| 127 | 5 | return $self; | |||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||
| 130 | # connect to DB | ||||||||||||||||||||||||||||||||
| 131 | sub connect | ||||||||||||||||||||||||||||||||
| 132 | 4 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
connect: called CC=10 SCAR=25.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 133 | 4 | my $self = shift; | |||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||
| 135 | 4 | ▶ | unless ( ref($self)) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 136 | # called as DBIx::Roles-> connect(), packages provided | ||||||||||||||||||||||||||||||||
| 137 | 0 | $self = $self-> new( @{shift()}); | |||||||||||||||||||||||||||||||
| 138 | } # else the object is just being reconnected | ||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||
| 140 | 4 | my $inst = $self-> instance; | |||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||
| 142 | 4 | ▶ | $self-> disconnect if $inst->{dbh}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||
| 144 | 4 | my @p = @_; | |||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||
| 146 | # ask each package what do they think about params to connect | ||||||||||||||||||||||||||||||||
| 147 | 4 | $inst-> dispatch( 'rewrite', 'connect', \@p); | |||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||
| 149 | # now, @p can be assumed to be in DBI-compatible format | ||||||||||||||||||||||||||||||||
| 150 | 4 | my ( $dsn, $user, $password, $attr) = @p; | |||||||||||||||||||||||||||||||
| 151 | 4 | ▶ | $attr ||= {}; | ||||||||||||||||||||||||||||||
|
Condition100%2/2
$attr ||= {}
MC/DC100%1/1
$attr ||= {}
$attr
Truth table100%2/2
A
A= $attr
| |||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||
| 153 | # validate each package's individual parameters | ||||||||||||||||||||||||||||||||
| 154 | 4 | for my $k ( keys %$attr) { | |||||||||||||||||||||||||||||||
| 155 | 2 | ▶ | next unless exists $inst->{defaults}->{$k}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 156 | 2 | $inst-> dispatch( 'STORE', $k, $attr->{$k}); | |||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||
| 159 | # apply eventual attributes passed from outside, | ||||||||||||||||||||||||||||||||
| 160 | # override with defaults those that have survived disconnect() | ||||||||||||||||||||||||||||||||
| 161 | 4 | for my $k ( keys %{$inst->{defaults}}) { | |||||||||||||||||||||||||||||||
| 162 | 40 | ▶ | if ( exists $attr-> {$k}) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 163 | 2 | $inst-> {attr}-> {$k} = $attr-> {$k}; | |||||||||||||||||||||||||||||||
| 164 | 2 | delete $attr-> {$k}; | |||||||||||||||||||||||||||||||
| 165 | } else { | ||||||||||||||||||||||||||||||||
| 166 | 38 | $inst-> {attr}-> {$k} = $inst->{defaults}->{$k}->[1]; | |||||||||||||||||||||||||||||||
| 167 | }; | ||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||
| 170 | # try to connect | ||||||||||||||||||||||||||||||||
| 171 | return $self | ||||||||||||||||||||||||||||||||
| 172 | 4 | ▶ | if $inst-> {dbh} = $inst-> connect( $dsn, $user, $password, $attr); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 173 | die "Unable to connect: no suitable roles found\n" | ||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | if $attr->{RaiseError}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 175 | 0 | return undef; | |||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||
| 178 | # access object data instance | ||||||||||||||||||||||||||||||||
| 179 | 26 | ▶ | sub instance { tied %{ $_[0] } } | ||||||||||||||||||||||||||||||
|
Subroutine
instance: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||
| 181 | # disconnect from DB, but retain the object | ||||||||||||||||||||||||||||||||
| 182 | sub disconnect | ||||||||||||||||||||||||||||||||
| 183 | 0 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
disconnect: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 184 | 0 | my $self = $_[0]; | |||||||||||||||||||||||||||||||
| 185 | 0 | my $inst = $self-> instance; | |||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||
| 187 | 0 | ▶ | $inst-> disconnect if $inst->{dbh}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||
| 190 | sub AUTOLOAD | ||||||||||||||||||||||||||||||||
| 191 | 12 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
AUTOLOAD: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||
| 192 | 12 | my @p = @_; | |||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||
| 194 | 1 | ▶ | use vars qw($AUTOLOAD); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 195 | 12 | my $method = $AUTOLOAD; | |||||||||||||||||||||||||||||||
| 196 | 12 | $method =~ s/^.*:://; | |||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||
| 198 | 12 | my $self = shift @p; | |||||||||||||||||||||||||||||||
| 199 | 12 | my $inst = $self-> instance; | |||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||
| 201 | 12 | my $package; | |||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||
| 203 | 12 | ▶ | if ( | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
exists $DBI::DBI_methods{"common"}{$method} or exists $DBI::DBI_methods{"db"}{$method}
MC/DC50%1/2
exists $DBI::DBI_methods{"common"}{$method} or exists $DBI::DBI_methods{"db"}{$method}
exists $DBI::DBI_methods{"common"}{$method}
exists $DBI::DBI_methods{"db"}{$method}
Truth table66%2/3
A or B
A= exists $DBI::DBI_methods{"common"}{$method}B= exists $DBI::DBI_methods{"db"}{$method}
| |||||||||||||||||||||||||||||||||
| 204 | exists( $DBI::DBI_methods{common}->{$method}) or | ||||||||||||||||||||||||||||||||
| 205 | exists( $DBI::DBI_methods{db}->{$method}) | ||||||||||||||||||||||||||||||||
| 206 | ) { | ||||||||||||||||||||||||||||||||
| 207 | # is it a DBI native method? | ||||||||||||||||||||||||||||||||
| 208 | # rewrite | ||||||||||||||||||||||||||||||||
| 209 | 9 | $inst-> dispatch( 'rewrite', $method, \@p); | |||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||
| 211 | # dispatch | ||||||||||||||||||||||||||||||||
| 212 | 9 | @_ = ( $inst, $method, @p); | |||||||||||||||||||||||||||||||
| 213 | 9 | goto $inst-> can('dispatch_dbi_method'); | |||||||||||||||||||||||||||||||
| 214 | } elsif ( exists $inst->{vmt}->{$method}) { | ||||||||||||||||||||||||||||||||
| 215 | # is it an exported method for outside usage? | ||||||||||||||||||||||||||||||||
| 216 | 1 | my $package = $inst->{vmt}->{$method}; | |||||||||||||||||||||||||||||||
| 217 | 1 | my $ref = $package-> can( $method); | |||||||||||||||||||||||||||||||
| 218 | 1 | ▶ | die "Package '$package' declared method '$method' as available, but it is not" | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 219 | unless $ref; # XXX AUTOLOAD cases are not handled | ||||||||||||||||||||||||||||||||
| 220 | 1 | @_ = ( $inst, $inst->{private}->{$package}, @p); | |||||||||||||||||||||||||||||||
| 221 | 1 | goto $ref; | |||||||||||||||||||||||||||||||
| 222 | } else { | ||||||||||||||||||||||||||||||||
| 223 | # none of the above, try wildcards | ||||||||||||||||||||||||||||||||
| 224 | 2 | @_ = ( $inst, 'any', $method, @p); | |||||||||||||||||||||||||||||||
| 225 | 2 | goto $inst-> can('dispatch'); | |||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||
| 229 | sub DESTROY | ||||||||||||||||||||||||||||||||
| 230 | 5 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 231 | 5 | my $self = $_[0]; | |||||||||||||||||||||||||||||||
| 232 | 5 | my $inst = $self-> instance; | |||||||||||||||||||||||||||||||
| 233 | 5 | ▶ | $inst-> disconnect if $inst->{dbh}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||
| 235 | 5 | untie %$inst; | |||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||
| 238 | # internal API | ||||||||||||||||||||||||||||||||
| 239 | package DBIx::Roles::Instance; | ||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||
| 241 | # since DBI::connect can be overloaded, call the connect method by reference | ||||||||||||||||||||||||||||||||
| 242 | 0 | ▶ | sub DBI_connect { shift; $DBIx::Roles::DBI_connect->('DBI', @_ ) } | ||||||||||||||||||||||||||||||
|
Subroutine
DBI_connect: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||
| 244 | # iterate through each package in the recursive way | ||||||||||||||||||||||||||||||||
| 245 | sub get_super | ||||||||||||||||||||||||||||||||
| 246 | 236 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
get_super: called CC=6 SCAR=18.0
| |||||||||||||||||||||||||||||||||
| 247 | 236 | my ( $self) = @_; | |||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||
| 249 | 236 | my $ref; | |||||||||||||||||||||||||||||||
| 250 | 236 | my $ctx = $self->{loops}->[-1]; | |||||||||||||||||||||||||||||||
| 251 | 236 | while ( 1) { | |||||||||||||||||||||||||||||||
| 252 | 724 | ▶ | if ( $ctx->[0] < scalar @{$self-> {packages}}) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 253 | # next package | ||||||||||||||||||||||||||||||||
| 254 | 695 | my $package = $self-> {packages}->[ $ctx->[0]++]; | |||||||||||||||||||||||||||||||
| 255 | 695 | ▶ | next if $self->{disabled}->{$package}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 256 | 695 | ▶ | next unless $ref = $package-> can( $ctx->[1]); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 257 | 0 | ▶ | print STDERR (' 'x @{$self->{loops}}), "-> $package\n" if $DBIx::Roles::debug; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 258 | 207 | return ( $ref, $self-> {private}-> {$package}); | |||||||||||||||||||||||||||||||
| 259 | } elsif ( $ctx->[2]) { | ||||||||||||||||||||||||||||||||
| 260 | # signal end of list | ||||||||||||||||||||||||||||||||
| 261 | 11 | return $ctx->[2]->( $self, $ctx); | |||||||||||||||||||||||||||||||
| 262 | } else { | ||||||||||||||||||||||||||||||||
| 263 | 18 | return; | |||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||
| 268 | # iterate through each package in the recursive way | ||||||||||||||||||||||||||||||||
| 269 | sub super | ||||||||||||||||||||||||||||||||
| 270 | 229 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
super: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 271 | 229 | my $self = shift; | |||||||||||||||||||||||||||||||
| 272 | 229 | my ( $ref, $private) = $self-> get_super; | |||||||||||||||||||||||||||||||
| 273 | 229 | ▶ | return unless $ref; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 274 | 211 | unshift @_, $self, $private; | |||||||||||||||||||||||||||||||
| 275 | 211 | goto $ref; | |||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||
| 278 | # saves and restores context of dispatch calls - needed if underlying roles | ||||||||||||||||||||||||||||||||
| 279 | # are needed to be restarted | ||||||||||||||||||||||||||||||||
| 280 | sub context | ||||||||||||||||||||||||||||||||
| 281 | 19 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
context: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 282 | 19 | ▶ | if ( $#_) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 283 | 6 | @{$_[0]->{loops}->[-1]} = @{$_[1]}; | |||||||||||||||||||||||||||||||
| 284 | } else { | ||||||||||||||||||||||||||||||||
| 285 | 13 | return [ @{$_[0]->{loops}->[-1]} ]; | |||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||
| 289 | # call $method in all packages, where available, returns the result of the call | ||||||||||||||||||||||||||||||||
| 290 | sub dispatch | ||||||||||||||||||||||||||||||||
| 291 | 74 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
dispatch: called CC=9 SCAR=23.2
| |||||||||||||||||||||||||||||||||
| 292 | 74 | my $self = shift; | |||||||||||||||||||||||||||||||
| 293 | 74 | ▶ | my $eol_handler = shift if $_[0] and ref($_[0]); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$_[0] and ref $_[0]
MC/DC50%1/2
$_[0] and ref $_[0]
$_[0]
ref $_[0]
Truth table66%2/3
A and B
A= $_[0]B= ref $_[0]
| |||||||||||||||||||||||||||||||||
| 294 | 74 | my $method = shift; | |||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||
| 296 | 74 | my @ret; | |||||||||||||||||||||||||||||||
| 297 | 74 | my $wa = wantarray; | |||||||||||||||||||||||||||||||
| 298 | 74 | push @{$self->{loops}}, [ 0, $method, $eol_handler, 0]; | |||||||||||||||||||||||||||||||
| 299 | 0 | print STDERR (' 'x @{$self->{loops}}), "dispatch(", | |||||||||||||||||||||||||||||||
| 300 | 0 | ▶ | ( join ',', map { defined($_) ? $_ : "undef"} $method,@_), ")\n" | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 301 | if $DBIx::Roles::debug; | ||||||||||||||||||||||||||||||||
| 302 | 74 | eval { | |||||||||||||||||||||||||||||||
| 303 | 74 | ▶ | if ( $wa) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 304 | 4 | @ret = $self-> super( @_); | |||||||||||||||||||||||||||||||
| 305 | } else { | ||||||||||||||||||||||||||||||||
| 306 | 70 | $ret[0] = $self-> super( @_); | |||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||
| 308 | }; | ||||||||||||||||||||||||||||||||
| 309 | 0 | ▶ | print STDERR (' 'x @{$self->{loops}}), "done $method\n" if $DBIx::Roles::debug; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 310 | 74 | pop @{$self->{loops}}; | |||||||||||||||||||||||||||||||
| 311 | 74 | ▶ | die $@ if $@; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 312 | 74 | ▶ | return wantarray ? @ret : $ret[0]; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||
| 315 | # if called, then that means that all $method hooks were called, | ||||||||||||||||||||||||||||||||
| 316 | # and now 'dbi_method' round must be run | ||||||||||||||||||||||||||||||||
| 317 | sub _dispatch_dbi_eol | ||||||||||||||||||||||||||||||||
| 318 | 11 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
_dispatch_dbi_eol: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||
| 319 | 11 | my ( $self, $ctx, $params) = @_; | |||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||
| 321 | 11 | $ctx->[0] = 0; # reset the counter | |||||||||||||||||||||||||||||||
| 322 | 11 | my $method = $ctx->[1]; | |||||||||||||||||||||||||||||||
| 323 | 11 | $ctx->[1] = 'dbi_method'; # call that hook instead | |||||||||||||||||||||||||||||||
| 324 | 11 | $ctx->[2] = undef; # clear the eol handler | |||||||||||||||||||||||||||||||
| 325 | 0 | ▶ | print STDERR (' 'x @{$self->{loops}}), "done($method),dispatch(dbi_method)\n" if $DBIx::Roles::debug; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 326 | 11 | ▶ | return sub { $_[0]-> super( $method, @_[2..$#_]) } | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 327 | 11 | } | |||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||
| 329 | # dispatch a native DBI method - first $method, then dbi_method hooks | ||||||||||||||||||||||||||||||||
| 330 | sub dispatch_dbi_method | ||||||||||||||||||||||||||||||||
| 331 | 24 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
dispatch_dbi_method: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 332 | 24 | my ( $self, $method, @parameters) = @_; | |||||||||||||||||||||||||||||||
| 333 | 24 | splice( @_, 1, 0, \&_dispatch_dbi_eol); | |||||||||||||||||||||||||||||||
| 334 | 24 | goto &dispatch; | |||||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||
| 337 | sub enable_roles | ||||||||||||||||||||||||||||||||
| 338 | 0 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
enable_roles: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||
| 339 | 0 | my $hash = shift->{disabled}; | |||||||||||||||||||||||||||||||
| 340 | 0 | for my $p (@_) { | |||||||||||||||||||||||||||||||
| 341 | 0 | ▶ | my $g = ($p =~ /:/) ? $p : "DBIx::Roles::$p"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 342 | 0 | ▶ | $hash->{$g}-- if $hash->{$g} > 0; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||
| 346 | sub disable_roles | ||||||||||||||||||||||||||||||||
| 347 | 0 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
disable_roles: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||
| 348 | 0 | my $hash = shift->{disabled}; | |||||||||||||||||||||||||||||||
| 349 | 0 | for my $p (@_) { | |||||||||||||||||||||||||||||||
| 350 | 0 | ▶ | my $g = ($p =~ /:/) ? $p : "DBIx::Roles::$p"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 351 | 0 | $hash->{$g}++; | |||||||||||||||||||||||||||||||
| 352 | } | ||||||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||
| 355 | # R/W access to the underlying DBI connection handle | ||||||||||||||||||||||||||||||||
| 356 | sub dbh | ||||||||||||||||||||||||||||||||
| 357 | 35 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
dbh: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 358 | 35 | ▶ | return $_[0]-> {dbh} unless $#_; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 359 | 12 | $_[0]-> {dbh} = $_[1]; | |||||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||
| 362 | # access to the DBIx::Roles object | ||||||||||||||||||||||||||||||||
| 363 | 4 | ▶ | sub object { $_[0]-> {self} } | ||||||||||||||||||||||||||||||
|
Subroutine
object: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||
| 365 | # all unknown functions, called by roles internally, are assumed to be DBI methods | ||||||||||||||||||||||||||||||||
| 366 | sub AUTOLOAD | ||||||||||||||||||||||||||||||||
| 367 | 15 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
AUTOLOAD: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 368 | 1 | ▶ | use vars qw($AUTOLOAD); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||
| 370 | 15 | my $method = $AUTOLOAD; | |||||||||||||||||||||||||||||||
| 371 | 15 | $method =~ s/^.*:://; | |||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||
| 373 | 15 | splice( @_, 1, 0, $method); | |||||||||||||||||||||||||||||||
| 374 | 15 | goto &dispatch_dbi_method; | |||||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||
| 377 | 5 | ▶ | sub TIEHASH { $_[1] } | ||||||||||||||||||||||||||||||
|
Subroutine
TIEHASH: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 378 | 4 | ▶ | sub EXISTS { shift-> dispatch( 'EXISTS', @_) } | ||||||||||||||||||||||||||||||
|
Subroutine
EXISTS: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 379 | 5 | ▶ | sub FETCH { shift-> dispatch( 'FETCH', @_) } | ||||||||||||||||||||||||||||||
|
Subroutine
FETCH: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 380 | 15 | ▶ | sub STORE { shift-> dispatch( 'STORE', @_) } | ||||||||||||||||||||||||||||||
|
Subroutine
STORE: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 381 | 4 | ▶ | sub DELETE { shift-> dispatch( 'DELETE', @_) } | ||||||||||||||||||||||||||||||
|
Subroutine
DELETE: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||
| 383 | 5 | ▶ | sub DESTROY { shift-> dispatch( 'DESTROY') } | ||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||
| 385 | package DBIx::Roles::Default; | ||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||
| 387 | sub connect | ||||||||||||||||||||||||||||||||
| 388 | 9 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
connect: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 389 | 9 | my ( $self, $storage, $dsn, $user, $password, $attr) = @_; | |||||||||||||||||||||||||||||||
| 390 | 9 | return $DBIx::Roles::DBI_connect->( 'DBI', $dsn, $user, $password, $attr); | |||||||||||||||||||||||||||||||
| 391 | } | ||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||
| 393 | sub disconnect | ||||||||||||||||||||||||||||||||
| 394 | 1 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
disconnect: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 395 | 1 | my $self = $_[0]; | |||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||
| 397 | 1 | $self-> {dbh}-> disconnect; | |||||||||||||||||||||||||||||||
| 398 | 1 | $self-> {dbh} = undef; | |||||||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||
| 401 | sub dbi_method | ||||||||||||||||||||||||||||||||
| 402 | 0 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
dbi_method: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 403 | 0 | my ( $self, $storage, $method, @parameters) = @_; | |||||||||||||||||||||||||||||||
| 404 | 0 | return $self-> {dbh}-> $method( @parameters); | |||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||
| 407 | sub any | ||||||||||||||||||||||||||||||||
| 408 | 0 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
any: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 409 | 0 | my ( $self, $storage, $method) = @_; | |||||||||||||||||||||||||||||||
| 410 | 0 | my @c = caller( $self-> {loops}->[-1]->[3] * 2); | |||||||||||||||||||||||||||||||
| 411 | 0 | die "Cannot locate method '$method' at $c[1] line $c[2]\n"; | |||||||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||
| 414 | sub EXISTS | ||||||||||||||||||||||||||||||||
| 415 | 4 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
EXISTS: called CC=2 SCAR=7.6
| |||||||||||||||||||||||||||||||||
| 416 | 4 | my ( $self, $storage, $key) = @_; | |||||||||||||||||||||||||||||||
| 417 | 4 | ▶ | if ( exists $self-> {attr}-> {$key}) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 418 | 0 | return exists $self-> {attr}-> {$key}; | |||||||||||||||||||||||||||||||
| 419 | } else { | ||||||||||||||||||||||||||||||||
| 420 | 4 | return exists $self-> {dbh}-> {$key}; | |||||||||||||||||||||||||||||||
| 421 | } | ||||||||||||||||||||||||||||||||
| 422 | } | ||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||
| 424 | sub FETCH | ||||||||||||||||||||||||||||||||
| 425 | 5 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
FETCH: called CC=2 SCAR=7.6
| |||||||||||||||||||||||||||||||||
| 426 | 5 | my ( $self, $storage, $key) = @_; | |||||||||||||||||||||||||||||||
| 427 | 5 | ▶ | if ( exists $self-> {attr}-> {$key}) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 428 | 5 | return $self-> {attr}-> {$key}; | |||||||||||||||||||||||||||||||
| 429 | } else { | ||||||||||||||||||||||||||||||||
| 430 | 0 | return $self-> {dbh}-> {$key}; | |||||||||||||||||||||||||||||||
| 431 | } | ||||||||||||||||||||||||||||||||
| 432 | } | ||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||
| 434 | sub STORE | ||||||||||||||||||||||||||||||||
| 435 | 17 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
STORE: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 436 | 17 | my ( $self, $storage, $key, $val) = @_; | |||||||||||||||||||||||||||||||
| 437 | 17 | ▶ | if ( exists $self-> {attr}-> {$key}) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 438 | 9 | $self-> {attr}-> {$key} = $val; | |||||||||||||||||||||||||||||||
| 439 | } else { | ||||||||||||||||||||||||||||||||
| 440 | 8 | $self-> {dbh}-> {$key} = $val; | |||||||||||||||||||||||||||||||
| 441 | } | ||||||||||||||||||||||||||||||||
| 442 | } | ||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||
| 444 | sub DELETE | ||||||||||||||||||||||||||||||||
| 445 | 4 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
DELETE: called CC=2 SCAR=7.6
| |||||||||||||||||||||||||||||||||
| 446 | 4 | my ( $self, $storage, $key) = @_; | |||||||||||||||||||||||||||||||
| 447 | 4 | ▶ | if ( exists $self-> {attr}-> {$key}) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 448 | 0 | delete $self-> {attr}-> {$key}; | |||||||||||||||||||||||||||||||
| 449 | } else { | ||||||||||||||||||||||||||||||||
| 450 | 4 | delete $self-> {dbh}-> {$key}; | |||||||||||||||||||||||||||||||
| 451 | } | ||||||||||||||||||||||||||||||||
| 452 | } | ||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||
| 454 | 1 | 1; | |||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||
| 456 | __DATA__ | ||||||||||||||||||||||||||||||||