| 1 | package Capture::Attribute::Return; | ||||||||||
| 2 | |||||||||||
| 3 | 2 | ▶ | use 5.010; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 2 | ▶ | BEGIN { | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 2 | $Capture::Attribute::Return::AUTHORITY = 'cpan:TOBYINK'; | |||||||||
| 8 | 2 | $Capture::Attribute::Return::VERSION = '0.003'; | |||||||||
| 9 | } | ||||||||||
| 10 | |||||||||||
| 11 | 2 | ▶ | use Any::Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | |||||||||||
| 13 | use overload | ||||||||||
| 14 | 2 | ▶ | '@{}' => '_ARRAY', | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | '""' => '_SCALAR', | ||||||||||
| 16 | 2 | '${}' => '_SCALAR'; | |||||||||
| 17 | |||||||||||
| 18 | 2 | has wasarray => ( | |||||||||
| 19 | is => 'ro', | ||||||||||
| 20 | isa => 'Num|Undef', | ||||||||||
| 21 | required => 1, | ||||||||||
| 22 | ); | ||||||||||
| 23 | |||||||||||
| 24 | 2 | has value => ( | |||||||||
| 25 | is => 'ro', | ||||||||||
| 26 | required => 0, | ||||||||||
| 27 | predicate => 'has_value', | ||||||||||
| 28 | ); | ||||||||||
| 29 | |||||||||||
| 30 | sub _ARRAY | ||||||||||
| 31 | 0 | ▶ | { | ||||||||
|
Subroutine
_ARRAY: not called CC=3 SCAR=24.8
| |||||||||||
| 32 | 0 | my ($self) = @_; | |||||||||
| 33 | 0 | ▶ | return [] if $self->is_void; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | 0 | ▶ | return $self->wasarray ? $self->value : [ $self->value ]; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 35 | } | ||||||||||
| 36 | |||||||||||
| 37 | sub _SCALAR | ||||||||||
| 38 | 0 | ▶ | { | ||||||||
|
Subroutine
_SCALAR: not called CC=3 SCAR=24.8
| |||||||||||
| 39 | 0 | my ($self) = @_; | |||||||||
| 40 | 0 | ▶ | return undef if $self->is_void; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 41 | 0 | ▶ | $self->wasarray ? do { my @a = @{$self->value}; scalar(@a) } : $self->value; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 42 | } | ||||||||||
| 43 | |||||||||||
| 44 | sub is_list | ||||||||||
| 45 | 1 | ▶ | { | ||||||||
|
Subroutine
is_list: called CC=2 SCAR=8.1
Pod
documented
| |||||||||||
| 46 | 1 | my ($self) = @_; | |||||||||
| 47 | 1 | ▶ | return 1 if $self->wasarray; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 48 | 0 | return; | |||||||||
| 49 | } | ||||||||||
| 50 | |||||||||||
| 51 | sub is_scalar | ||||||||||
| 52 | 1 | ▶ | { | ||||||||
|
Subroutine
is_scalar: called CC=3 SCAR=12.0
Pod
documented
| |||||||||||
| 53 | 1 | my ($self) = @_; | |||||||||
| 54 | 1 | my $wasarray = $self->wasarray; | |||||||||
| 55 | 1 | ▶ | return if $wasarray; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 56 | 1 | ▶ | return 1 if defined $wasarray; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 57 | 0 | return; | |||||||||
| 58 | } | ||||||||||
| 59 | |||||||||||
| 60 | sub is_void | ||||||||||
| 61 | 0 | ▶ | { | ||||||||
|
Subroutine
is_void: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 62 | 0 | my ($self) = @_; | |||||||||
| 63 | 0 | ▶ | return if defined $self->wasarray; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 64 | 0 | return 1; | |||||||||
| 65 | } | ||||||||||
| 66 | |||||||||||
| 67 | 2 | __PACKAGE__ | |||||||||
| 68 | __END__ | ||||||||||