Maypole/View.pm untested

filter: Statementstmt 0.0% 0 / 35 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 52 CC 2 SCAR 10.6
CC
2
Cov
0%
template
6.0
paths
2.0
BEGIN
2.0
CRAP 2.9
1 package MasonX::Maypole::View;
2 use warnings;
3 use strict;
4
5 use Maypole::Constants;
6 use Memoize;
7 use Symbol 'qualify_to_ref';
8
9 use base 'Maypole::View::Base';
10
11 =head1 NAME
12
13 MasonX::Maypole::View - Mason view subclass for MasonX::Maypole + Maypole 2
14
15 =head1 SYNOPSIS
16
17 See L<MasonX::Maypole|MasonX::Maypole>.
18
19 =head1 METHODS
20
21 =over
22
23 =item template
24
25 Loads the Maypole template vars into Mason components' namespace.
26
27 =cut
28
29 sub template
30 {
31 my ( $self, $r ) = @_;
32
33 my $pkg = $r->config->masonx->{in_package};
34
35 my %vars = $self->vars( $r );
36
37 warn __PACKAGE__ . " - template vars maybe not getting cleaned up" if $r->debug > 1;
38
39 foreach my $varname ( keys %vars )
40 {
41 my $export = qualify_to_ref( $varname, $pkg );
42 *$export = \$vars{ $varname };
43
44 # this does _not_ seem to be cleaning up always?
45 $r->ar->register_cleanup( sub { undef *$export; 1 } );
46 }
47
48 return OK;
49 }
50
51 =item paths
52
53 Builds the list of component roots in the correct order for Mason to search:
54
55 table-specific - if path exists
56 custom - if path exists
57 template root
58 factory
59
60 =cut
61
62 memoize( 'paths', NORMALIZER => sub { shift; my $r = shift; $r->model_class || ref $r } );
63
64 # this returns config info, so should be in the controller
65 sub paths
66 {
67 my ( $self, $r ) = @_;
68
69 return $r->_paths;
70 }
71
72 1;
73