| 1 | 5 | ▶ | use 5.006; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 2 | 5 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 3 | 5 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | package LINQ::Field; | ||||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | 5 | our $AUTHORITY = 'cpan:TOBYINK'; | |||||||||||||||||||
| 8 | 5 | our $VERSION = '0.003'; | |||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | 5 | ▶ | use Class::Tiny qw( index name value params ); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | 83 | ▶ | sub BUILD { | ||||||||||||||||||
|
Subroutine
BUILD: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 13 | 83 | my ( $self ) = ( shift ); | |||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | 83 | ▶ | if ( not $self->{params} ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 16 | 7 | $self->{params} = {}; | |||||||||||||||||||
| 17 | } | ||||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | 83 | ▶ | if ( not defined $self->{name} ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 20 | 79 | ▶ | if ( defined $self->{params}{as} ) { | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 21 | 11 | $self->{name} = $self->{params}{as}; | |||||||||||||||||||
| 22 | } | ||||||||||||||||||||
| 23 | ▶ | elsif ( !ref $self->{value} and $self->{value} =~ /\A[^\W0-9]\w*\z/ ) { | |||||||||||||||||||
|
Condition100%3/3
not ref $self->{"value"} and $self->{"value"} =~ /\A[^\W0-9]\w*\z/
MC/DC100%2/2
not ref $self->{"value"} and $self->{"value"} =~ /\A[^\W0-9]\w*\z/
not ref $self->{"value"}
$self->{"value"} =~ /\A[^\W0-9]\w*\z/
Truth table100%3/3
not(A) and B
A= not ref $self->{"value"}B= $self->{"value"} =~ /\A[^\W0-9]\w*\z/
| |||||||||||||||||||||
| 24 | 66 | $self->{name} = $self->{value}; | |||||||||||||||||||
| 25 | } | ||||||||||||||||||||
| 26 | else { | ||||||||||||||||||||
| 27 | 2 | $self->{name} = sprintf( '_%d', $self->{index} ); | |||||||||||||||||||
| 28 | } | ||||||||||||||||||||
| 29 | } #/ if ( not defined $self...) | ||||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | } #/ sub BUILD | ||||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | 81 | ▶ | sub getter { | ||||||||||||||||||
|
Subroutine
getter: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 34 | 81 | my ( $self ) = @_; | |||||||||||||||||||
| 35 | 81 | ▶ | $self->{getter} ||= $self->_build_getter; | ||||||||||||||||||
|
Condition100%3/3
$self->{"getter"} ||= $self->_build_getter
MC/DC100%2/2
$self->{"getter"} ||= $self->_build_getter
$self->{"getter"}
$self->_build_getter
Truth table100%3/3
A ||= B
A= $self->{"getter"}B= $self->_build_getter
| |||||||||||||||||||||
| 36 | } | ||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | 68 | ▶ | sub _build_getter { | ||||||||||||||||||
|
Subroutine
_build_getter: called CC=2 SCAR=6.9
| |||||||||||||||||||||
| 39 | 68 | my ( $self ) = @_; | |||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | 68 | my $attr = $self->value; | |||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | 68 | ▶ | if ( ref( $attr ) eq 'CODE' ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 44 | 4 | return $attr; | |||||||||||||||||||
| 45 | } | ||||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | 64 | require Scalar::Util; | |||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | 153 | ▶ | return sub { | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||
| 50 | 153 | my $blessed = Scalar::Util::blessed( $_ ); | |||||||||||||||||||
| 51 | 153 | ▶ | if ( ( $blessed || '' ) =~ /\AObject::Adhoc::__ANON__::/ ) { | ||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$blessed || ''
MC/DC100%1/1
$blessed || ''
$blessed
Truth table100%2/2
A
A= $blessed
| |||||||||||||||||||||
| 52 | 96 | $blessed = undef; | |||||||||||||||||||
| 53 | } | ||||||||||||||||||||
| 54 | 153 | ▶ | scalar( $blessed ? $_->$attr : $_->{$attr} ); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 55 | 64 | }; | |||||||||||||||||||
| 56 | } #/ sub _build_getter | ||||||||||||||||||||
| 57 | |||||||||||||||||||||
| 58 | 5 | 1; | |||||||||||||||||||
| 59 | |||||||||||||||||||||
| 60 | __END__ | ||||||||||||||||||||