| 1 | 7 | ▶ | use 5.008003; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 2 | 7 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 3 | 7 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 4 | 7 | ▶ | no warnings qw( void once uninitialized ); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||
| 6 | package Lexical::Accessor; | ||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||
| 8 | 7 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 9 | 7 | ▶ | use Sub::Accessor::Small (); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||
| 11 | 7 | our $AUTHORITY = 'cpan:TOBYINK'; | |||||||||||||||||||||||||||||||||||||
| 12 | 7 | our $VERSION = '1.001002'; | |||||||||||||||||||||||||||||||||||||
| 13 | 7 | our @EXPORT = qw/ lexical_has /; | |||||||||||||||||||||||||||||||||||||
| 14 | 7 | our @ISA = qw/ Sub::Accessor::Small /; | |||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||
| 16 | 7 | ▶ | sub _generate_lexical_has : method | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_generate_lexical_has: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 17 | { | ||||||||||||||||||||||||||||||||||||||
| 18 | 7 | my $me = shift; | |||||||||||||||||||||||||||||||||||||
| 19 | 7 | my $code = $me->_generate_has(@_); | |||||||||||||||||||||||||||||||||||||
| 20 | 7 | return Sub::Accessor::Small::set_subname( "$me\::lexical_has", $code ); | |||||||||||||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||
| 23 | 0 | ▶ | sub lexical_has : method | ||||||||||||||||||||||||||||||||||||
|
Subroutine
lexical_has: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 24 | { | ||||||||||||||||||||||||||||||||||||||
| 25 | 0 | my $has = $_[0]->can('has'); | |||||||||||||||||||||||||||||||||||||
| 26 | 0 | goto $has; | |||||||||||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||
| 29 | 42 | ▶ | sub inline_to_coderef : method | ||||||||||||||||||||||||||||||||||||
|
Subroutine
inline_to_coderef: called CC=3 SCAR=12.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 30 | { | ||||||||||||||||||||||||||||||||||||||
| 31 | 42 | my $me = shift; | |||||||||||||||||||||||||||||||||||||
| 32 | 42 | my ($method_type, $code) = @_; | |||||||||||||||||||||||||||||||||||||
| 33 | 42 | my $coderef = $me->SUPER::inline_to_coderef(@_); | |||||||||||||||||||||||||||||||||||||
| 34 | ( $me->{package} and defined $me->{slot} ) | ||||||||||||||||||||||||||||||||||||||
| 35 | 42 | ▶ | ? Sub::Accessor::Small::set_subname( "$me->{package}\::__LEXICAL__[$me->{slot}]", $coderef ) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$me->{"package"} and defined $me->{"slot"}
MC/DC0%0/2
$me->{"package"} and defined $me->{"slot"}
$me->{"package"}
defined $me->{"slot"}
Truth table33%1/3
A and B
A= $me->{"package"}B= defined $me->{"slot"}
| |||||||||||||||||||||||||||||||||||||||
| 36 | : $coderef | ||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||
| 39 | 42 | ▶ | sub accessor_kind : method | ||||||||||||||||||||||||||||||||||||
|
Subroutine
accessor_kind: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 40 | { | ||||||||||||||||||||||||||||||||||||||
| 41 | 42 | return 'lexical'; | |||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||
| 44 | 26 | ▶ | sub canonicalize_is : method | ||||||||||||||||||||||||||||||||||||
|
Subroutine
canonicalize_is: called CC=13 SCAR=27.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 45 | { | ||||||||||||||||||||||||||||||||||||||
| 46 | 26 | my $me = shift; | |||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||
| 48 | 26 | ▶ | if ($me->{is} eq 'rw') | ||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||
| 49 | { | ||||||||||||||||||||||||||||||||||||||
| 50 | $me->{accessor} = \(my $tmp) | ||||||||||||||||||||||||||||||||||||||
| 51 | 5 | ▶ | if !exists($me->{accessor}); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||
| 53 | elsif ($me->{is} eq 'ro') | ||||||||||||||||||||||||||||||||||||||
| 54 | { | ||||||||||||||||||||||||||||||||||||||
| 55 | $me->{reader} = \(my $tmp) | ||||||||||||||||||||||||||||||||||||||
| 56 | 4 | ▶ | if !exists($me->{reader}); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||
| 58 | elsif ($me->{is} eq 'rwp') | ||||||||||||||||||||||||||||||||||||||
| 59 | { | ||||||||||||||||||||||||||||||||||||||
| 60 | $me->{reader} = \(my $tmp1) | ||||||||||||||||||||||||||||||||||||||
| 61 | 4 | ▶ | if !exists($me->{reader}); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 62 | $me->{writer} = \(my $tmp2) | ||||||||||||||||||||||||||||||||||||||
| 63 | 4 | ▶ | if !exists($me->{writer}); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||
| 65 | elsif ($me->{is} eq 'lazy') | ||||||||||||||||||||||||||||||||||||||
| 66 | { | ||||||||||||||||||||||||||||||||||||||
| 67 | $me->{reader} = \(my $tmp) | ||||||||||||||||||||||||||||||||||||||
| 68 | 4 | ▶ | if !exists($me->{reader}); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 69 | $me->{lazy} = 1 | ||||||||||||||||||||||||||||||||||||||
| 70 | 4 | ▶ | if !exists($me->{lazy}); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 71 | $me->{builder} = 1 | ||||||||||||||||||||||||||||||||||||||
| 72 | 4 | ▶ | unless $me->{builder} || $me->{default}; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$me->{"builder"} or $me->{"default"}
MC/DC0%0/2
$me->{"builder"} or $me->{"default"}
$me->{"builder"}
$me->{"default"}
Truth table33%1/3
A or B
A= $me->{"builder"}B= $me->{"default"}
| |||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||
| 76 | 26 | ▶ | sub canonicalize_opts : method | ||||||||||||||||||||||||||||||||||||
|
Subroutine
canonicalize_opts: called CC=8 SCAR=23.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 77 | { | ||||||||||||||||||||||||||||||||||||||
| 78 | 26 | my $me = shift; | |||||||||||||||||||||||||||||||||||||
| 79 | 26 | $me->SUPER::canonicalize_opts(@_); | |||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||
| 81 | 26 | ▶ | if (defined $me->{init_arg}) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 82 | { | ||||||||||||||||||||||||||||||||||||||
| 83 | 0 | croak("Invalid init_arg=>defined; private attributes cannot be initialized in the constructor"); | |||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||
| 86 | 26 | ▶ | if ($me->{required}) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 87 | { | ||||||||||||||||||||||||||||||||||||||
| 88 | 0 | croak("Invalid required=>1; private attributes cannot be initialized in the constructor"); | |||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||
| 91 | 26 | ▶ | if (defined $me->{lazy} and not $me->{lazy}) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $me->{"lazy"} and not $me->{"lazy"}
MC/DC0%0/2
defined $me->{"lazy"} and not $me->{"lazy"}
defined $me->{"lazy"}
not $me->{"lazy"}
Truth table66%2/3
A and not(B)
A= defined $me->{"lazy"}B= not $me->{"lazy"}
| |||||||||||||||||||||||||||||||||||||||
| 92 | { | ||||||||||||||||||||||||||||||||||||||
| 93 | 0 | croak("Invalid lazy=>0; private attributes cannot be eager"); | |||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||
| 95 | else | ||||||||||||||||||||||||||||||||||||||
| 96 | { | ||||||||||||||||||||||||||||||||||||||
| 97 | 26 | ▶ | $me->{lazy} ||= 1 if $me->{default} || $me->{builder}; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition80%4/5
$me->{"default"} or $me->{"builder"}
$me->{"lazy"} ||= 1
MC/DC50%1/2
$me->{"default"} or $me->{"builder"}
$me->{"default"}
$me->{"builder"}
MC/DC100%1/1
$me->{"lazy"} ||= 1
$me->{"lazy"}
Truth table66%2/3
A or B
A= $me->{"default"}B= $me->{"builder"}
Truth table100%2/2
A
A= $me->{"lazy"}
| |||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||
| 100 | # for my $type (qw/ reader writer accessor clearer predicate /) | ||||||||||||||||||||||||||||||||||||||
| 101 | # { | ||||||||||||||||||||||||||||||||||||||
| 102 | # if (defined($me->{$type}) and not ref($me->{$type}) eq q(SCALAR)) | ||||||||||||||||||||||||||||||||||||||
| 103 | # { | ||||||||||||||||||||||||||||||||||||||
| 104 | # croak("Expected $type to be a scalar ref; not '$me->{$type}'"); | ||||||||||||||||||||||||||||||||||||||
| 105 | # } | ||||||||||||||||||||||||||||||||||||||
| 106 | # } | ||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||
| 109 | sub expand_handles | ||||||||||||||||||||||||||||||||||||||
| 110 | 1 | ▶ | { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
expand_handles: called CC=2 SCAR=7.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 111 | 1 | my $me = shift; | |||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||
| 113 | 1 | ▶ | if (ref($me->{handles}) eq q(ARRAY)) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 114 | { | ||||||||||||||||||||||||||||||||||||||
| 115 | 1 | return @{$me->{handles}}; | |||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||
| 118 | 0 | croak "Expected delegations to be a reference to an array; got $me->{handles}"; | |||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||
| 121 | 7 | 1; | |||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||
| 123 | __END__ | ||||||||||||||||||||||||||||||||||||||