| 1 | package Syntax::Feature::CatalystAction; | ||||||||||||
| 2 | |||||||||||||
| 3 | 2 | ▶ | use 5.008008; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 2 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | 2 | ▶ | use warnings FATAL =>'all'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | |||||||||||||
| 7 | 2 | our $VERSION = '0.01'; | |||||||||||
| 8 | |||||||||||||
| 9 | 2 | ▶ | use CatalystX::Syntax::Action (); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 10 | 2 | ▶ | use B::Hooks::EndOfScope; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 11 | 2 | ▶ | use Carp (); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 12 | 2 | ▶ | use namespace::clean; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 13 | |||||||||||||
| 14 | 2 | $Carp::Internal{ +__PACKAGE__ }++; | |||||||||||
| 15 | |||||||||||||
| 16 | 1 | ▶ | sub install { | ||||||||||
|
Subroutine
install: called CC=3 SCAR=11.1
Pod
undocumented
| |||||||||||||
| 17 | 1 | my ($class, %args) = @_; | |||||||||||
| 18 | 1 | my $target = $args{into}; | |||||||||||
| 19 | 1 | ▶ | my $name = $args{options}{ -as } || 'action'; | ||||||||||
|
Condition50%1/2
$args{'options'}{'-as'} || 'action'
MC/DC0%0/1
$args{'options'}{'-as'} || 'action'
$args{'options'}{'-as'}
Truth table50%1/2
A
A= $args{'options'}{'-as'}
| |||||||||||||
| 20 | 1 | ▶ | my $invocant = $args{options}{ -invocant } || '$self'; | ||||||||||
|
Condition50%1/2
$args{'options'}{'-invocant'} || '$self'
MC/DC0%0/1
$args{'options'}{'-invocant'} || '$self'
$args{'options'}{'-invocant'}
Truth table50%1/2
A
A= $args{'options'}{'-invocant'}
| |||||||||||||
| 21 | |||||||||||||
| 22 | 1 | CatalystX::Syntax::Action->import( | |||||||||||
| 23 | into => $target, | ||||||||||||
| 24 | name => $name, | ||||||||||||
| 25 | invocant => $invocant, | ||||||||||||
| 26 | ); | ||||||||||||
| 27 | |||||||||||||
| 28 | 1 | ▶ | on_scope_end { | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 29 | 1 | namespace::clean->clean_subroutines($target, $name); | |||||||||||
| 30 | 1 | }; | |||||||||||
| 31 | |||||||||||||
| 32 | 1 | return 1; | |||||||||||
| 33 | } | ||||||||||||
| 34 | |||||||||||||
| 35 | 2 | 1; | |||||||||||
| 36 | |||||||||||||
| 37 | =head1 NAME | ||||||||||||
| 38 | |||||||||||||
| 39 | Syntax::Feature::CatalystAction - Provide an action keyword to Catalyst Controllers | ||||||||||||
| 40 | |||||||||||||
| 41 | =head1 SYNOPSIS | ||||||||||||
| 42 | |||||||||||||
| 43 | package MyApp::Web::Controller::Foo; | ||||||||||||
| 44 | |||||||||||||
| 45 | use Moose; | ||||||||||||
| 46 | use namespace::autoclean; | ||||||||||||
| 47 | use syntax 'catalyst_action'; | ||||||||||||
| 48 | |||||||||||||
| 49 | extends 'Catalyst::Controller'; | ||||||||||||
| 50 | |||||||||||||
| 51 | action my_action($arg) : Path('my_special_action') Args(1) | ||||||||||||
| 52 | { | ||||||||||||
| 53 | $ctx->response->body('Look ma, no "my ($self, $ctx, $arg) = @_;" | ||||||||||||
| 54 | } | ||||||||||||
| 55 | |||||||||||||
| 56 | __PACKAGE__->meta->make_immutable; | ||||||||||||
| 57 | |||||||||||||
| 58 | =head1 DESCRIPTION | ||||||||||||
| 59 | |||||||||||||
| 60 | This module is a L<syntax> compatible wrapper for L<CatalystX::Syntax::Action>. | ||||||||||||
| 61 | Please see that module for documentation and examples. The main reason you | ||||||||||||
| 62 | might wish to use this instead is that it makes it easier to install multiple | ||||||||||||
| 63 | syntax extensions at once. For example: | ||||||||||||
| 64 | |||||||||||||
| 65 | package MyApp::Web::Controller::Foo; | ||||||||||||
| 66 | |||||||||||||
| 67 | use Moose; | ||||||||||||
| 68 | use syntax qw(method function catalyst_action); | ||||||||||||
| 69 | |||||||||||||
| 70 | extends 'Catalyst::Controller'; | ||||||||||||
| 71 | |||||||||||||
| 72 | action my_action: Action { ... } | ||||||||||||
| 73 | |||||||||||||
| 74 | method my_method { | ||||||||||||
| 75 | ... | ||||||||||||
| 76 | return function($arg1, $arg2) { ... }; | ||||||||||||
| 77 | } | ||||||||||||
| 78 | |||||||||||||
| 79 | =head1 AUTHOR | ||||||||||||
| 80 | |||||||||||||
| 81 | John Napiorkowski L<email:jjnapiork@cpan.org> | ||||||||||||
| 82 | |||||||||||||
| 83 | =head1 SEE ALSO | ||||||||||||
| 84 | |||||||||||||
| 85 | L<Catalyst>, L<Syntax::Feature::Method>, L<syntax>, L<Devel::Declare> | ||||||||||||
| 86 | |||||||||||||
| 87 | =head1 COPYRIGHT & LICENSE | ||||||||||||
| 88 | |||||||||||||
| 89 | Copyright 2011, John Napiorkowski L<email:jjnapiork@cpan.org> | ||||||||||||
| 90 | |||||||||||||
| 91 | This library is free software; you can redistribute it and/or modify it under | ||||||||||||
| 92 | the same terms as Perl itself. | ||||||||||||
| 93 | |||||||||||||
| 94 | =cut | ||||||||||||