| 1 | package Class::Data::Localize; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 4 | ▶ | use strict qw(vars subs); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 4 | ▶ | use vars qw($VERSION); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 4 | $VERSION = '0.0401'; | |||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 4 | ▶ | use ReleaseAction (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 15 | ▶ | sub mk_classdata { | ||||||||||||||||||||||||||
|
Subroutine
mk_classdata: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 10 | 15 | my ($declaredclass, $attribute, $data) = @_; | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 15 | ▶ | if( ref $declaredclass ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 13 | 1 | require Carp; | |||||||||||||||||||||||||||
| 14 | 1 | Carp::croak("mk_classdata() is a class method, not an object method"); | |||||||||||||||||||||||||||
| 15 | } | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 53 | ▶ | my $accessor = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=7 SCAR=19.6
| |||||||||||||||||||||||||||||
| 18 | 53 | ▶ | my $wantclass = ref($_[0]) || $_[0]; | ||||||||||||||||||||||||||
|
Condition66%2/3
ref $_[0] || $_[0]
MC/DC0%0/2
ref $_[0] || $_[0]
ref $_[0]
$_[0]
Truth table66%2/3
A || B
A= ref $_[0]B= $_[0]
| |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 53 | ▶ | if(@_==3) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 21 | 10 | my $current = $data; | |||||||||||||||||||||||||||
| 22 | 10 | ▶ | $_[2] = ReleaseAction->new( sub { $data = $current } ); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 10 | ▶ | if($wantclass ne $declaredclass){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 25 | 0 | return mk_classdata($wantclass,$attribute,$data)->(@_); | |||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||
| 28 | else { | ||||||||||||||||||||||||||||
| 29 | 43 | ▶ | return mk_classdata($wantclass,$attribute)->(@_) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@_ > 1 and $wantclass ne $declaredclass
MC/DC100%2/2
@_ > 1 and $wantclass ne $declaredclass
@_ > 1
$wantclass ne $declaredclass
Truth table100%3/3
A and B
A= @_ > 1B= $wantclass ne $declaredclass
| |||||||||||||||||||||||||||||
| 30 | if @_>1 && $wantclass ne $declaredclass; | ||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | 47 | ▶ | $data = $_[1] if @_>1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 33 | 47 | return $data; | |||||||||||||||||||||||||||
| 34 | 14 | }; | |||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 14 | my $alias = "_${attribute}_accessor"; | |||||||||||||||||||||||||||
| 37 | 14 | *{$declaredclass.'::'.$attribute} = $accessor; | |||||||||||||||||||||||||||
| 38 | 14 | *{$declaredclass.'::'.$alias} = $accessor; | |||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 4 | 1; | |||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | __END__ | ||||||||||||||||||||||||||||