File: Controller.pm

package info (click to toggle)
libmojolicious-perl 0.999926-1%2Bsqueeze2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 1,672 kB
  • ctags: 949
  • sloc: perl: 17,391; makefile: 4
file content (74 lines) | stat: -rw-r--r-- 1,686 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# Copyright (C) 2008-2010, Sebastian Riedel.

package MojoX::Dispatcher::Routes::Controller;

use strict;
use warnings;

use base 'MojoX::Session::Cookie::Controller';

require Carp;
require Scalar::Util;

__PACKAGE__->attr('match');

# Just make a simple cake. And this time, if someone's going to jump out of
# it make sure to put them in *after* you cook it.
sub param {
    my $self = shift;

    # Parameters
    my $params = $self->stash->{params} || $self->req->params;
    Carp::croak(qq/Stash value "params" is not a "Mojo::Parameters" object./)
      unless ref $params
          && Scalar::Util::blessed($params)
          && $params->isa('Mojo::Parameters');

    # Values
    return wantarray ? ($params->param(@_)) : scalar $params->param(@_);
}

1;
__END__

=head1 NAME

MojoX::Dispatcher::Routes::Controller - Controller Base Class

=head1 SYNOPSIS

    use base 'MojoX::Dispatcher::Routes::Controller';

=head1 DESCRIPTION

L<MojoX::Dispatcher::Routes::Controller> is a controller base class.

=head1 ATTRIBUTES

L<MojoX::Dispatcher::Routes::Controller> inherits all attributes from
L<MojoX::Session::Cookie::Controller> implements the following attributes.

=head2 C<match>

    my $m = $c->match;

A L<MojoX::Routes::Match> object containing the routes results for the
current request.

=head1 METHODS

L<MojoX::Dispatcher::Routes::Controller> inherits all methods from
L<MojoX::Session::Cookie::Controller> and implements the following new ones.

=head2 C<param>

    my $param  = $c->param('foo');
    my @params = $c->param('foo');

Request parameters and routes captures.

=head1 SEE ALSO

L<Mojolicious>, L<Mojolicious::Guides>, L<http://mojolicious.org>.

=cut