Commit | Line | Data |
---|---|---|
fbcc39ad | 1 | package Catalyst::Action; |
2 | ||
3 | use strict; | |
4 | use base qw/Class::Accessor::Fast/; | |
5 | ||
11bd4e3e | 6 | __PACKAGE__->mk_accessors(qw/class namespace reverse attributes name code/); |
fbcc39ad | 7 | |
8 | use overload ( | |
9 | ||
10 | # Stringify to reverse for debug output etc. | |
11 | q{""} => sub { shift->{reverse} }, | |
12 | ||
13 | # Codulate to encapsulated action coderef | |
14 | '&{}' => sub { shift->{code} }, | |
15 | ||
6a064886 | 16 | # Make general $stuff still work |
17 | fallback => 1, | |
18 | ||
fbcc39ad | 19 | ); |
20 | ||
21 | =head1 NAME | |
22 | ||
23 | Catalyst::Action - Catalyst Action | |
24 | ||
25 | =head1 SYNOPSIS | |
26 | ||
27 | See L<Catalyst>. | |
28 | ||
29 | =head1 DESCRIPTION | |
30 | ||
31 | =head1 METHODS | |
32 | ||
b5ecfcf0 | 33 | =head2 attributes |
fbcc39ad | 34 | |
b5ecfcf0 | 35 | =head2 class |
b96f127f | 36 | |
b5ecfcf0 | 37 | =head2 code |
11bd4e3e | 38 | |
b5ecfcf0 | 39 | =head2 execute |
fbcc39ad | 40 | |
41 | =cut | |
42 | ||
43 | sub execute { # Execute ourselves against a context | |
44 | my ( $self, $c ) = @_; | |
261c571e | 45 | local $c->namespace = $self->namespace; |
11bd4e3e | 46 | return $c->execute( $self->class, $self ); |
fbcc39ad | 47 | } |
48 | ||
4082e678 | 49 | =head2 match |
50 | ||
51 | =cut | |
52 | ||
53 | sub match { | |
54 | my ( $self, $c ) = @_; | |
55 | return 1 unless exists $self->attributes->{Args}; | |
56 | return scalar(@{$c->req->args}) == $self->attributes->{Args}[0]; | |
57 | } | |
58 | ||
b5ecfcf0 | 59 | =head2 namespace |
fbcc39ad | 60 | |
b5ecfcf0 | 61 | =head2 reverse |
6b239949 | 62 | |
b5ecfcf0 | 63 | =head2 name |
fbcc39ad | 64 | |
65 | =head1 AUTHOR | |
66 | ||
67 | Matt S. Trout | |
68 | ||
69 | =head1 COPYRIGHT | |
70 | ||
71 | This program is free software, you can redistribute it and/or modify it under | |
72 | the same terms as Perl itself. | |
73 | ||
74 | =cut | |
75 | ||
76 | 1; |