Jifty::Plugin::ViewDeclarePage - sexy replacement for suckish Jifty::View::Declare::Page


Jifty documentation Contained in the Jifty distribution.

Index


Code Index:

NAME

Top

Jifty::Plugin::ViewDeclarePage - sexy replacement for suckish Jifty::View::Declare::Page

DESCRIPTION

Top

All you need you'll find in Jifty::Plugin::ViewDeclarePage::Page doc.

Name sucks and I'm open for suggestions it's not late to rename.

METHODS

Top

init

Called during initialization. Tries to load YourApp::View::Page that is used by default as page implementation. If it's not there then simple is generated, otherwise checked if your page class is sub class of Jifty::Plugin::ViewDeclarePage::Page and warning is issued if it's not.

LICENSE

Top

Under the same terms as perl itself.

AUTHOR

Top

Ruslan Zakirov <Ruslan.Zakirov@gmail.com>


Jifty documentation Contained in the Jifty distribution.
use strict;
use warnings;

package Jifty::Plugin::ViewDeclarePage;
use base qw/Jifty::Plugin/;

our $VERSION = '0.01';

sub init {
    my $self = shift;
    my $class = Jifty->app_class('View::Page');
    if ( Jifty::Util->try_to_require($class) ) {
        Jifty->log->warn(
            "Plugin '". __PACKAGE__ ."' is used,"
            ." but class '$class' is not subclass of '". __PACKAGE__ ."::Page'"
        ) unless $class->isa( __PACKAGE__ .'::Page' );
    } else {
        my $page_class = __PACKAGE__ .'::Page';
        eval "package $class; use strict; use warnings; use base '$page_class'; 1;"
            or die $@;
        Jifty->log->debug("Generated simple '$class' class");
    }
    return 1;
}

1;