File: Visit.pm

package info (click to toggle)
libcatalyst-perl 5.90132-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,016 kB
  • sloc: perl: 11,061; makefile: 7
file content (104 lines) | stat: -rw-r--r-- 2,378 bytes parent folder | download | duplicates (12)
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
package TestApp::Controller::Action::Visit;

use strict;
use base 'TestApp::Controller::Action';

sub one : Local {
    my ( $self, $c ) = @_;
    $c->visit('two');
}

sub two : Private {
    my ( $self, $c ) = @_;
    $c->visit('three');
}

sub three : Local {
    my ( $self, $c ) = @_;
    $c->visit( $self, 'four' );
}

sub four : Private {
    my ( $self, $c ) = @_;
    $c->visit('/action/visit/five');
}

sub five : Local {
    my ( $self, $c ) = @_;
    $c->forward('View::Dump::Request');
}

sub inheritance : Local {
    my ( $self, $c ) = @_;
    $c->visit('/action/inheritance/a/b/default');
}

sub global : Local {
    my ( $self, $c ) = @_;
    $c->visit('/global_action');
}

sub with_args : Local {
    my ( $self, $c, $arg ) = @_;
    $c->visit( 'args', [$arg] );
}

sub with_method_and_args : Local {
    my ( $self, $c, $arg ) = @_;
    $c->visit( qw/TestApp::Controller::Action::Visit args/, [$arg] );
}

sub args : Local {
    my ( $self, $c, $val ) = @_;
    die "passed argument does not match args" unless $val eq $c->req->args->[0];
    $c->res->body($val);
}

sub visit_die : Local {
    my ( $self, $c, $val ) = @_;
    eval { $c->visit( 'args', [qq/new/] ) };
    $c->res->body( $@ ? $@ : "visit() doesn't die" );
}

sub visit_chained : Local {
    my ( $self, $c, $val, $capture, @args ) = @_;
    my @cap_and_args = ([$capture], [@args]);
      $val eq 1 ? $c->visit( '/action/chained/foo/spoon',                                 @cap_and_args)
    : $val eq 2 ? $c->visit( qw/ Action::Chained::Foo spoon /,                            @cap_and_args)
    :             $c->visit( $c->controller('Action::Chained::Foo')->action_for('spoon'), @cap_and_args)
}

sub view : Local {
    my ( $self, $c, $val ) = @_;
    eval { $c->visit('View::Dump') };
    $c->res->body( $@ ? $@ : "visit() did not die" );
}

sub model : Local {
    my ( $self, $c, $val ) = @_;
    eval { $c->visit('Model::Foo') };
    $c->res->body( $@ ? $@ : "visit() did not die" );
}

sub args_embed_relative : Local {
    my ( $self, $c ) = @_;
    $c->visit('embed/ok');
}

sub args_embed_absolute : Local {
    my ( $self, $c ) = @_;
    $c->visit('/action/visit/embed/ok');
}

sub embed : Local {
    my ( $self, $c, $ok ) = @_;
    $ok ||= 'not ok';
    $c->res->body($ok);
}

sub class_visit_test_action : Local {
    my ( $self, $c ) = @_;
    $c->visit(qw/TestApp/);
}

1;