NAME

Egg::Plugin::Dispatch - It is a base class for Dispatch.

SYNOPSIS

  use base qw/Egg::Plugin::Dispatch/;
  
  __PACKAGE__->run_modes( ... );
  
  __PACKAGE__->default_mode( ... );
  
  $e->dispatch;

DESCRIPTION

This is a base class for the Dispatch plugin.

To do the function as Dispatch of Egg, necessary minimum method is offered.

EXPORT FUNCTION

It is a function compulsorily exported by the controller of the project.

code ( [PACKAGE_NAME], [METHOD_NAME] )

PACKAGE_NAME is read, and the code reference of METHOD_NAME is returned.

Please give PACKAGE_NAME the module name since the project name.

Using it because of the setting of run_modes etc. is convenient for this method.

  # The CODE reference of the content method of MyApp::Dispatch is set.
  # * In this case, ($dispatch, $e) extends to the content method.
  package MyApp;
  .......
  ...
  __PACKAGE__->egg_startup(
    .......
    ...
    content => code( Dispatch => 'content' ),
    );
  
  # When using it in the code. * An arbitrary argument is passed.
  $e->code( Dispatch => 'content' )->($e, ... args );

METHODS

run_modes ( [RUN_MODE_HASH] )

Received RUN_MODE_HASH is set in the global variable of the project.

RUN_MODE_HASH set to omit RUN_MODE_HASH is returned.

  __PACKAGE__->run_modes (
    _default => sub {},
    hoge     => sub { ... },
    );

default_mode ( [DEFAULT_MODE] )

Received DEFAULT_MODE is set in the global variable of the project.

* '_' is put when there is no first '_' of the character string.

DEFAULT_MODE set to omit DEFAULT_MODE is returned.

* Default is '_default'.

  __PACKAGE__->default_mode( '_index' )
  • Alias: start_mode

mode_param ( [MODE_PARAM_NAME] )

The parameter name to decide the action of dispatch is setup.

  __PACKAGE__->mode_param( 'mode' );

* If the access control of the URI base is done, it is not necessary to set it especially.

dispatch

The exception is generated when there is no dispatch method in the succession class.

HANDLER METHODS

Basic method for main body of dispatch.

e

Accessor to Egg object.

stash

Accessor to $e->stash. * However, contents are the HASH references.

run_modes

Accessor to HASH reference set with run_modes.

action

Accessor for storage of list of matched run_modes key.

* The thing that is the ARRAY reference is hoped for without fail.

label

Accessor for label and list storage picked up from action.

* The thing that is the ARRAY reference is hoped for without fail.

page_title

Accessor that assumes thing that label or key to action finally matched is put.

default_mode

Accessor to value set in default_mode.

default_name

The value of 'template_default_name' of $e->config is returned.

new

Constructor.

  shift->SUPER::new(@_);

target_action

The URI passing to decided action is assembled and it returns it.

_start

Method that is called from Egg for the most much correspondence to hook for the first dispatch.

_action

Method of favorite that is called from Egg for dispatch processing.

_finish

Method that is called from Egg for the most much correspondence to hook for the last dispatch.

reset

Alias to '_initialize' method.

* Any method of '_initialize' of this module is not done.

_example_code

It is a method that calls from Egg::Helper::BlankPage.

For contents offer of sample Dispatch published in sample page.

SEE ALSO

Egg::Release,

AUTHOR

Masatoshi Mizuno <lushe@cpan.org>

COPYRIGHT

Copyright (C) 2007 by Bee Flag, Corp. <http://egg.bomcity.com/>, All Rights Reserved.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.