| 1 | package Class::MixinFactory::InsideOutAttr; | ||||||||||||||
| 2 | |||||||||||||||
| 3 | 8 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 4 | |||||||||||||||
| 5 | ######################################################################## | ||||||||||||||
| 6 | |||||||||||||||
| 7 | 16 | ▶ | sub import { | ||||||||||||
|
Subroutine
import: called CC=3 SCAR=11.0
| |||||||||||||||
| 8 | 16 | my $methodmaker = shift; | |||||||||||||
| 9 | 16 | my $target_class = ( caller )[0]; | |||||||||||||
| 10 | 8 | ▶ | no strict 'refs'; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 11 | 16 | foreach my $attr ( @_ ) { | |||||||||||||
| 12 | 32 | ▶ | *{ $target_class . '::' . $attr } = sub { inside_out( $attr, @_ ) } | ||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||
| 13 | 32 | } | |||||||||||||
| 14 | 16 | defined *{ $target_class . '::' . 'DESTROY' }{CODE} | |||||||||||||
| 15 | 16 | ▶ | or *{ $target_class . '::' . 'DESTROY' } = \&destroy; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 16 | } | ||||||||||||||
| 17 | |||||||||||||||
| 18 | 8 | my %inside_out; | |||||||||||||
| 19 | |||||||||||||||
| 20 | 276 | ▶ | sub inside_out { | ||||||||||||
|
Subroutine
inside_out: called CC=3 SCAR=11.2
Pod
undocumented
| |||||||||||||||
| 21 | 276 | my $callee = shift; | |||||||||||||
| 22 | 276 | my $key = shift; | |||||||||||||
| 23 | 276 | ▶ | if ( $key eq 'DESTROY' ) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 24 | 0 | delete $inside_out{ $callee }; | |||||||||||||
| 25 | } elsif ( ! scalar @_ ) { | ||||||||||||||
| 26 | 261 | $inside_out{ $callee }{ $key } | |||||||||||||
| 27 | } else { | ||||||||||||||
| 28 | 15 | $inside_out{ $callee }{ $key } = shift; | |||||||||||||
| 29 | } | ||||||||||||||
| 30 | } | ||||||||||||||
| 31 | |||||||||||||||
| 32 | 2 | ▶ | sub destroy { | ||||||||||||
|
Subroutine
destroy: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||
| 33 | 2 | my $callee = shift; | |||||||||||||
| 34 | 2 | delete $inside_out{ $callee }; | |||||||||||||
| 35 | } | ||||||||||||||
| 36 | |||||||||||||||
| 37 | ######################################################################## | ||||||||||||||
| 38 | |||||||||||||||
| 39 | 8 | 1; | |||||||||||||
| 40 | |||||||||||||||
| 41 | __END__ | ||||||||||||||