| 1 | package Class::MixinFactory::Factory; | ||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||
| 3 | 8 | $VERSION = 0.91; | |||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||
| 5 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||
| 7 | 8 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 8 | 8 | ▶ | use Carp (); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||
| 10 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||
| 12 | 8 | ▶ | use Class::MixinFactory::InsideOutAttr qw(base_class mixin_prefix mixed_prefix); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||
| 14 | 8 | ▶ | use Class::MixinFactory::NEXT; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 15 | 69 | ▶ | sub next_dispatch_class { 'Class::MixinFactory::NEXT' } | ||||||||||||||||||||||||||||||||||||
|
Subroutine
next_dispatch_class: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||
| 17 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||
| 19 | 4 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 20 | 4 | my $sym; | |||||||||||||||||||||||||||||||||||||
| 21 | 4 | my $self = bless \$sym, shift; | |||||||||||||||||||||||||||||||||||||
| 22 | 4 | ▶ | while ( my $method = shift @_ ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 23 | 2 | $self->$method( shift ); | |||||||||||||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||||||||||||
| 25 | 4 | $self; | |||||||||||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||
| 28 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||
| 30 | 78 | ▶ | sub class { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
class: called CC=14 SCAR=28.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 31 | 78 | my $factory = shift; | |||||||||||||||||||||||||||||||||||||
| 32 | 0 | ▶ | my @mixins = ( @_ == 1 and ref($_[0]) ) ? @{ $_[0] } : @_; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@_ == 1 and ref $_[0]
MC/DC0%0/2
@_ == 1 and ref $_[0]
@_ == 1
ref $_[0]
Truth table66%2/3
A and B
A= @_ == 1B= ref $_[0]
| |||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||
| 34 | 78 | my $base_class = $factory->base_class(); | |||||||||||||||||||||||||||||||||||||
| 35 | 78 | ▶ | my $mixin_prefix = $factory->mixin_prefix() || $base_class || ''; | ||||||||||||||||||||||||||||||||||||
|
Condition60%3/5
$factory->mixin_prefix || $base_class || ''
$factory->mixin_prefix or $base_class
MC/DC0%0/2
$factory->mixin_prefix || $base_class || ''
$factory->mixin_prefix
$base_class
Truth table66%2/3
A or B
A= $factory->mixin_prefixB= $base_class
| |||||||||||||||||||||||||||||||||||||||
| 36 | 78 | ▶ | my $mixed_prefix = $factory->mixed_prefix() || ( $base_class ? $base_class : ref($factory) || $factory ) . "::AUTO"; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition40%2/5
$factory->mixed_prefix || ($base_class ? $base_class : ref $factory || $factory) . '::AUTO'
ref $factory or $factory
MC/DC100%1/1
$factory->mixed_prefix || ($base_class ? $base_class : ref $factory || $factory) . '::AUTO'
$factory->mixed_prefix
MC/DC0%0/2
ref $factory or $factory
ref $factory
$factory
Truth table100%2/2
A
A= $factory->mixed_prefix
Truth table0%0/3
A or B
A= ref $factoryB= $factory
| |||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||
| 38 | 78 | ▶ | my @classes = map { ( $_ =~ /::/ ) ? $_ : $mixin_prefix ? $mixin_prefix . '::' . $_ : $_ } @mixins; | ||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||
| 40 | 78 | my $label = join '_', map { s/^\Q$mixin_prefix\E:://; s/:://g; $_ } map "$_", @classes; | |||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||
| 42 | 78 | ▶ | my $new_class = $mixed_prefix . "::" . ( $label || "Base" ); | ||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$label || 'Base'
MC/DC100%1/1
$label || 'Base'
$label
Truth table100%2/2
A
A= $label
| |||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||
| 44 | 8 | ▶ | return $new_class if do { no strict 'refs'; @{ "$new_class\::ISA" } }; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||
| 46 | 69 | my @isa = ( @classes, $base_class, $factory->next_dispatch_class ); | |||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||
| 48 | 69 | foreach my $package ( @classes ) { | |||||||||||||||||||||||||||||||||||||
| 49 | 8 | ▶ | next if do { no strict 'refs'; scalar keys %{ $package . '::' } }; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 50 | 0 | my $filename = "$package.pm"; | |||||||||||||||||||||||||||||||||||||
| 51 | 0 | $filename =~ s{::}{/}g; | |||||||||||||||||||||||||||||||||||||
| 52 | # warn "require $filename"; | ||||||||||||||||||||||||||||||||||||||
| 53 | 0 | require $filename; | |||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||
| 56 | 8 | ▶ | { no strict; @{ "$new_class\::ISA" } = @isa; } | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||
| 58 | 69 | $new_class; | |||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||
| 61 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||
| 63 | 8 | 1; | |||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||
| 65 | __END__ | ||||||||||||||||||||||||||||||||||||||