| 1 | 34 | ▶ | use 5.008; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | 34 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 34 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | package Class::Scaffold::Factory::Type; | ||||||||||||||||||||||||||||
| 6 | 34 | ▶ | BEGIN { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 34 | $Class::Scaffold::Factory::Type::VERSION = '1.102280'; | |||||||||||||||||||||||||||
| 8 | } | ||||||||||||||||||||||||||||
| 9 | # ABSTRACT: Factory for framework object types | ||||||||||||||||||||||||||||
| 10 | 34 | ▶ | use parent 'Class::Factory::Enhanced'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 41 | ▶ | sub import { | ||||||||||||||||||||||||||
|
Subroutine
import: called CC=4 SCAR=18.5
| |||||||||||||||||||||||||||||
| 13 | 41 | shift; # We don't need the package name | |||||||||||||||||||||||||||
| 14 | 41 | my $spec = shift; | |||||||||||||||||||||||||||
| 15 | 41 | ▶ | return unless defined $spec && $spec eq ':all'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $spec and $spec eq ":all"
MC/DC0%0/2
defined $spec and $spec eq ":all"
defined $spec
$spec eq ":all"
Truth table33%1/3
A and B
A= defined $specB= $spec eq ":all"
| |||||||||||||||||||||||||||||
| 16 | 0 | my $pkg = caller; | |||||||||||||||||||||||||||
| 17 | 0 | for my $symbol (Class::Scaffold::Factory::Type->get_registered_types) { | |||||||||||||||||||||||||||
| 18 | 0 | my $factory_class = | |||||||||||||||||||||||||||
| 19 | Class::Scaffold::Factory::Type->get_registered_class($symbol); | ||||||||||||||||||||||||||||
| 20 | 34 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | 0 | my $target = "${pkg}::obj_${symbol}"; | |||||||||||||||||||||||||||
| 22 | 0 | ▶ | *$target = sub () { $factory_class }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | # override this method with a caching version; it's called very often | ||||||||||||||||||||||||||||
| 27 | 0 | ▶ | sub make_object_for_type { | ||||||||||||||||||||||||||
|
Subroutine
make_object_for_type: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 28 | 0 | my ($self, $object_type, @args) = @_; | |||||||||||||||||||||||||||
| 29 | 0 | our %cache; | |||||||||||||||||||||||||||
| 30 | 0 | ▶ | my $class = $cache{$object_type} ||= $self->get_factory_class($object_type); | ||||||||||||||||||||||||||
|
Condition0%0/3
$Class::Scaffold::Factory::Type::cache{$object_type} ||= $self->get_factory_class($object_type)
MC/DC0%0/2
$Class::Scaffold::Factory::Type::cache{$object_type} ||= $self->get_factory_class($object_type)
$Class::Scaffold::Factory::Type::cache{$object_type}
$self->get_factory_class($object_type)
Truth table0%0/3
A ||= B
A= $Class::Scaffold::Factory::Type::cache{$object_type}B= $self->get_factory_class($object_type)
| |||||||||||||||||||||||||||||
| 31 | 0 | $class->new(@args); | |||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | # no warnings | ||||||||||||||||||||||||||||
| 35 | 0 | ▶ | sub factory_log { } | ||||||||||||||||||||||||||
|
Subroutine
factory_log: not called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 8 | ▶ | sub register_factory_type { | ||||||||||||||||||||||||||
|
Subroutine
register_factory_type: called CC=3 SCAR=15.1
Pod
documented
| |||||||||||||||||||||||||||||
| 38 | 8 | my ($item, @args) = @_; | |||||||||||||||||||||||||||
| 39 | 8 | $item->SUPER::register_factory_type(@args); | |||||||||||||||||||||||||||
| 40 | 8 | ▶ | return unless $::PTAGS; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | 0 | ▶ | while (my ($factory_type, $package) = splice @args, 0, 2) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 42 | 0 | $::PTAGS->add_tag("csft--$factory_type", "filename_for:$package", 1); | |||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | 34 | 1; | |||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | __END__ | ||||||||||||||||||||||||||||