CatalystX::Declare::Keyword::Application - Declare Catalyst Application Classes


CatalystX-Declare documentation Contained in the CatalystX-Declare distribution.

Index


NAME

Top

CatalystX::Declare::Keyword::Application - Declare Catalyst Application Classes

SYNOPSIS

Top

    use CatalystX::Declare;

    application MyApp::Web
           with Static::Simple
           with ConfigLoader {

        $CLASS->config(name => 'My App');

        method debug_timestamp {
            $self->log->debug('Timestamp: ' . time)
                if $self->debug;
        }
    }

DESCRIPTION

Top

This module provides a keyword handler for the application keyword. It is an extension of class in MooseX::Declare. The role application mechanism behind the with specification is hijacked and the arguments are passed to Catalyst's setup method. This hijacking is proably going away someday since in the future plugins will be actual roles.

You don't have to call the setup method yourself, this will be done by the handler after the body has been run.

SUPERCLASSES

Top

MooseX::Declare::Syntax::Keyword::Class

METHODS

Top

auto_make_immutable

    Bool Object->auto_make_immutable ()

A modified method that returns 0 to signal to MooseX::Declare that it should not make this class immutable. Currently, making application classes immutable isn't supported yet, therefore is mutable is currently a no-op. This will likely change as soon as application classes can be made immutable,

context_traits

    List[ClassName] Object->context_traits ()

This extends the remaining context traits with CatalystX::Declare::Context::AppSetup to manage calls to MyApp->setup in Catalyst.

add_with_option_customizations

    Object->add_with_option_customizations (
        Object   $ctx, 
        Str      $package,
        ArrayRef $plugins,
        HashRef  $options
    )

This will prepare MyApp->setup in Catalyst to be called with the list of plugins that were specified as roles.

add_namespace_customizations

    Object->add_namespace_customizations (Object $ctx, Str $package)

This will prepare Catalyst as a parent and import CLASS into the application's namespace before the other customizations are run.

add_optional_customizations

    Object->add_optional_customizations (Object $ctx, Str $package)

After all customizations have been done, this modifier will push a call to MyApp->setup in Catalyst if this wasn't already done by the plugin specifications.

SEE ALSO

Top

CatalystX::Declare
class in MooseX::Declare
MooseX::Declare::Syntax::Keyword::Class

AUTHOR

Top

See AUTHOR in CatalystX::Declare for author information.

LICENSE

Top

This program is free software; you can redistribute it and/or modify it under the same terms as perl itself.


CatalystX-Declare documentation Contained in the CatalystX-Declare distribution.

use MooseX::Declare;

class CatalystX::Declare::Keyword::Application
    extends MooseX::Declare::Syntax::Keyword::Class {

    use aliased 'CatalystX::Declare::Context::AppSetup';

    
    override auto_make_immutable { 0 }

    around context_traits { $self->$orig, AppSetup }

    override add_with_option_customizations (Object $ctx, Str $package, ArrayRef $plugins, HashRef $options) {

        $ctx->add_setup_code_parts($package, $plugins)
    }

    before add_namespace_customizations (Object $ctx, Str $package) {

        $ctx->add_preamble_code_parts(
            'use CLASS',
            'use parent q{Catalyst}',
        );
    }

    after add_optional_customizations (Object $ctx, Str $package) {

        $ctx->add_setup_code_parts($package)
            unless $ctx->setup_was_called;
    }
}