| 1 | package MasonX::Component::Interp; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 1 | ▶ | use Class::Inspector; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | use Scalar::Util qw/reftype/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 1 | ▶ | use base qw/HTML::Mason::Interp/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | =head1 METHODS | ||||||||||
| 11 | |||||||||||
| 12 | =head2 new | ||||||||||
| 13 | |||||||||||
| 14 | =over 4 | ||||||||||
| 15 | |||||||||||
| 16 | =item Arguments: %params | ||||||||||
| 17 | |||||||||||
| 18 | =item Return Value: $interp | ||||||||||
| 19 | |||||||||||
| 20 | =back | ||||||||||
| 21 | |||||||||||
| 22 | =cut | ||||||||||
| 23 | |||||||||||
| 24 | 0 | ▶ | sub new { | ||||||||
|
Subroutine
new: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||
| 25 | 0 | my ($self, %attrs) = @_; | |||||||||
| 26 | |||||||||||
| 27 | my $comp_root = exists $attrs{comp_root} | ||||||||||
| 28 | ? $attrs{comp_root} | ||||||||||
| 29 | 0 | ▶ | : $self->validation_spec->{comp_root}->{default}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 30 | |||||||||||
| 31 | 0 | ▶ | if (!ref $comp_root) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 32 | 0 | $comp_root = [ [ MAIN => $comp_root ] ]; | |||||||||
| 33 | } | ||||||||||
| 34 | |||||||||||
| 35 | 0 | ▶ | if (reftype $comp_root eq 'ARRAY') { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 36 | 0 | my @additional_comp_roots = $self->registry->comp_roots; | |||||||||
| 37 | 0 | push @{ $comp_root }, @additional_comp_roots; | |||||||||
| 38 | } | ||||||||||
| 39 | |||||||||||
| 40 | 0 | $attrs{comp_root} = $comp_root; | |||||||||
| 41 | |||||||||||
| 42 | 0 | return $self->SUPER::new(%attrs); | |||||||||
| 43 | } | ||||||||||
| 44 | |||||||||||
| 45 | =head2 registry_class | ||||||||||
| 46 | |||||||||||
| 47 | =over 4 | ||||||||||
| 48 | |||||||||||
| 49 | =item Arguments: none | ||||||||||
| 50 | |||||||||||
| 51 | =item Return Value: $class | ||||||||||
| 52 | |||||||||||
| 53 | =back | ||||||||||
| 54 | |||||||||||
| 55 | =cut | ||||||||||
| 56 | |||||||||||
| 57 | 0 | ▶ | sub registry_class { | ||||||||
|
Subroutine
registry_class: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 58 | 0 | return 'MasonX::Component::Registry'; | |||||||||
| 59 | } | ||||||||||
| 60 | |||||||||||
| 61 | =head2 registry | ||||||||||
| 62 | |||||||||||
| 63 | =over 4 | ||||||||||
| 64 | |||||||||||
| 65 | =item Arguments: none | ||||||||||
| 66 | |||||||||||
| 67 | =item Return Value: $class | ||||||||||
| 68 | |||||||||||
| 69 | =back | ||||||||||
| 70 | |||||||||||
| 71 | =cut | ||||||||||
| 72 | |||||||||||
| 73 | 0 | ▶ | sub registry { | ||||||||
|
Subroutine
registry: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 74 | 0 | my ($self) = @_; | |||||||||
| 75 | |||||||||||
| 76 | 0 | my $class = $self->registry_class; | |||||||||
| 77 | 0 | $self->ensure_class_loaded($class); | |||||||||
| 78 | |||||||||||
| 79 | 0 | return $class; | |||||||||
| 80 | } | ||||||||||
| 81 | |||||||||||
| 82 | =head2 ensure_class_loaded | ||||||||||
| 83 | |||||||||||
| 84 | =over 4 | ||||||||||
| 85 | |||||||||||
| 86 | =item Arguments: none | ||||||||||
| 87 | |||||||||||
| 88 | =item Return Value: none | ||||||||||
| 89 | |||||||||||
| 90 | =back | ||||||||||
| 91 | |||||||||||
| 92 | =cut | ||||||||||
| 93 | |||||||||||
| 94 | 0 | ▶ | sub ensure_class_loaded { | ||||||||
|
Subroutine
ensure_class_loaded: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||
| 95 | 0 | my ($self, $class) = @_; | |||||||||
| 96 | |||||||||||
| 97 | 0 | ▶ | croak "Invalid class name $class" | ||||||||
|
Branch: 1 branch
| |||||||||||
| 98 | if $class =~ /(?:\b:\b|\:{3,})/; | ||||||||||
| 99 | |||||||||||
| 100 | 0 | ▶ | return if Class::Inspector->loaded($class); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 101 | |||||||||||
| 102 | 0 | eval "require $class"; | |||||||||
| 103 | 0 | ▶ | if (my $error = $@) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 104 | 0 | croak $error; | |||||||||
| 105 | } | ||||||||||
| 106 | |||||||||||
| 107 | 0 | return; | |||||||||
| 108 | } | ||||||||||
| 109 | |||||||||||
| 110 | 1 | 1; | |||||||||