| 1 | 1 | ▶ | use 5.008; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 2 | 1 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 4 | |||||||||||||||
| 5 | package Class::Scaffold::Factory; | ||||||||||||||
| 6 | 1 | ▶ | BEGIN { | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 7 | 1 | $Class::Scaffold::Factory::VERSION = '1.102280'; | |||||||||||||
| 8 | } | ||||||||||||||
| 9 | # ABSTRACT: Base class for framework factories | ||||||||||||||
| 10 | 1 | ▶ | use Error; # to get $Error::Depth; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 11 | 1 | ▶ | use Error::Hierarchy::Util qw/assert_defined load_class/; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 12 | 1 | ▶ | use parent 'Class::Scaffold::Storable'; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 13 | |||||||||||||||
| 14 | 0 | ▶ | sub notify_lookup_failure { | ||||||||||||
|
Subroutine
notify_lookup_failure: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||
| 15 | 0 | my ($self, $handler_type, $spec) = @_; | |||||||||||||
| 16 | 0 | local $Error::Depth = $Error::Depth + 1; | |||||||||||||
| 17 | 0 | throw Class::Scaffold::Exception::NoSuchFactoryHandler( | |||||||||||||
| 18 | handler_type => $handler_type, | ||||||||||||||
| 19 | spec => join(', ', @$spec), | ||||||||||||||
| 20 | ); | ||||||||||||||
| 21 | } | ||||||||||||||
| 22 | |||||||||||||||
| 23 | 0 | ▶ | sub get_class_name_for_handler { | ||||||||||||
|
Subroutine
get_class_name_for_handler: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||
| 24 | 0 | my ($self, $handler_type, $spec) = @_; | |||||||||||||
| 25 | 0 | assert_defined $handler_type, 'called without handler_type.'; | |||||||||||||
| 26 | 0 | my $class = $self->every_hash($handler_type); | |||||||||||||
| 27 | 0 | for my $spec_el (@$spec) { | |||||||||||||
| 28 | |||||||||||||||
| 29 | # Stringify potential value object as using it as a hash key doesn't | ||||||||||||||
| 30 | # trigger stringification automatically | ||||||||||||||
| 31 | 0 | ▶ | if (exists $class->{"$spec_el"}) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 32 | 0 | $class = $class->{"$spec_el"}; | |||||||||||||
| 33 | } elsif (exists $class->{_AUTO}) { | ||||||||||||||
| 34 | 0 | $class = $class->{_AUTO}; | |||||||||||||
| 35 | |||||||||||||||
| 36 | # ignore the rest of the spec | ||||||||||||||
| 37 | 0 | last; | |||||||||||||
| 38 | } else { | ||||||||||||||
| 39 | 0 | $self->notify_lookup_failure($handler_type, $spec); | |||||||||||||
| 40 | 0 | return; # undef to signal failure | |||||||||||||
| 41 | } | ||||||||||||||
| 42 | } | ||||||||||||||
| 43 | 0 | $class; | |||||||||||||
| 44 | } | ||||||||||||||
| 45 | |||||||||||||||
| 46 | 0 | ▶ | sub gen_handler { | ||||||||||||
|
Subroutine
gen_handler: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||
| 47 | 0 | my ($self, $handler_type, $spec, %args) = @_; | |||||||||||||
| 48 | 0 | my $class = $self->get_class_name_for_handler($handler_type, $spec); | |||||||||||||
| 49 | 0 | load_class $class, $self->delegate->test_mode; | |||||||||||||
| 50 | 0 | $class->new( | |||||||||||||
| 51 | storage_type => $self->storage_type, | ||||||||||||||
| 52 | %args | ||||||||||||||
| 53 | ); | ||||||||||||||
| 54 | } | ||||||||||||||
| 55 | 1 | 1; | |||||||||||||
| 56 | |||||||||||||||
| 57 | |||||||||||||||
| 58 | __END__ | ||||||||||||||