Jifty/Plugin/ViewDeclarePage.pm untested

filter: Statementstmt 0.0% 0 / 18 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 30 CC 3 SCAR 19.5
CC
3
Cov
0%
init
12.0
BEGIN
2.0
BEGIN
2.0
CRAP 7.0
1 use strict;
2 use warnings;
3  
4 package Jifty::Plugin::ViewDeclarePage;
5 use base qw/Jifty::Plugin/;
6  
7 our $VERSION = '0.01';
8  
9 =head1 NAME
10  
11 Jifty::Plugin::ViewDeclarePage - sexy replacement for suckish Jifty::View::Declare::Page
12  
13 =head1 DESCRIPTION
14  
15 All you need you'll find in L<Jifty::Plugin::ViewDeclarePage::Page> doc.
16  
17 Name sucks and I'm open for suggestions it's not late to rename.
18  
19 =head1 METHODS
20  
21 =head2 init
22  
23 Called during initialization. Tries to load YourApp::View::Page that
24 is used by default as page implementation. If it's not there then
25 simple is generated, otherwise checked if your page class is sub
26 class of L<Jifty::Plugin::ViewDeclarePage::Page> and warning is issued
27 if it's not.
28  
29 =cut
30  
31 sub init {
32 my $self = shift;
33 my $class = Jifty->app_class('View::Page');
34 if ( Jifty::Util->try_to_require($class) ) {
35 Jifty->log->warn(
36 "Plugin '". __PACKAGE__ ."' is used,"
37 ." but class '$class' is not subclass of '". __PACKAGE__ ."::Page'"
38 ) unless $class->isa( __PACKAGE__ .'::Page' );
39 } else {
40 my $page_class = __PACKAGE__ .'::Page';
41 eval "package $class; use strict; use warnings; use base '$page_class'; 1;"
42 or die $@;
43 Jifty->log->debug("Generated simple '$class' class");
44 }
45 return 1;
46 }
47  
48 =head1 LICENSE
49  
50 Under the same terms as perl itself.
51  
52 =head1 AUTHOR
53  
54 Ruslan Zakirov E<lt>Ruslan.Zakirov@gmail.comE<gt>
55  
56 =cut
57  
58 1;