| 1 | package Thunderhorse::Controller; | ||||||||||
| 2 | 24 | $Thunderhorse::Controller::VERSION = '0.107'; | |||||||||
| 3 | 24 | ▶ | use v5.40; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 24 | ▶ | use Mooish::Base -standard; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 24 | ▶ | use Thunderhorse::Context::Facade; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 24 | ▶ | use URI; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 24 | extends 'Gears::Controller'; | |||||||||
| 10 | 24 | with 'Thunderhorse::Autoloadable'; | |||||||||
| 11 | |||||||||||
| 12 | 24 | has extended 'app' => ( | |||||||||
| 13 | handles => [ | ||||||||||
| 14 | qw( | ||||||||||
| 15 | loop | ||||||||||
| 16 | config | ||||||||||
| 17 | ) | ||||||||||
| 18 | ], | ||||||||||
| 19 | ); | ||||||||||
| 20 | |||||||||||
| 21 | 98 | ▶ | sub make_facade ($self, $ctx) | ||||||||
|
Subroutine
make_facade: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 22 | { | ||||||||||
| 23 | 98 | return Thunderhorse::Context::Facade->new(context => $ctx); | |||||||||
| 24 | } | ||||||||||
| 25 | |||||||||||
| 26 | 66 | ▶ | sub router ($self) | ||||||||
|
Subroutine
router: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 27 | { | ||||||||||
| 28 | 66 | my $router = $self->app->router; | |||||||||
| 29 | 66 | $router->set_controller($self); | |||||||||
| 30 | 66 | return $router; | |||||||||
| 31 | } | ||||||||||
| 32 | |||||||||||
| 33 | 17 | ▶ | sub _run_method ($self, $method, @args) | ||||||||
|
Subroutine
_run_method: called CC=3 SCAR=11.0
| |||||||||||
| 34 | { | ||||||||||
| 35 | 17 | ▶ | die "no such method $method" | ||||||||
|
Branch: 1 branch
| |||||||||||
| 36 | unless ref $self; | ||||||||||
| 37 | |||||||||||
| 38 | 17 | my $module_method = $self->app->extra_methods->{controller}{$method}; | |||||||||
| 39 | |||||||||||
| 40 | 17 | ▶ | die "no such method $method" | ||||||||
|
Branch: 1 branch
| |||||||||||
| 41 | unless $module_method; | ||||||||||
| 42 | |||||||||||
| 43 | 14 | return $module_method->($self, @args); | |||||||||
| 44 | } | ||||||||||
| 45 | |||||||||||
| 46 | 1 | ▶ | sub _can_method ($self, $method) | ||||||||
|
Subroutine
_can_method: called CC=1 SCAR=0.0
| |||||||||||
| 47 | { | ||||||||||
| 48 | 1 | return $self->app->extra_methods->{controller}{$method}; | |||||||||
| 49 | } | ||||||||||
| 50 | |||||||||||
| 51 | 11 | ▶ | sub url_for ($self, $name, @args) | ||||||||
|
Subroutine
url_for: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 52 | { | ||||||||||
| 53 | 11 | my $loc = $self->router->find($name); | |||||||||
| 54 | 11 | ▶ | Gears::X::Thunderhorse->raise("no such route '$name'") | ||||||||
|
Branch: 1 branch
| |||||||||||
| 55 | unless defined $loc; | ||||||||||
| 56 | |||||||||||
| 57 | 9 | return $loc->build(@args); | |||||||||
| 58 | } | ||||||||||
| 59 | |||||||||||
| 60 | 6 | ▶ | sub abs_url ($self, $url = '') | ||||||||
|
Subroutine
abs_url: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 61 | { | ||||||||||
| 62 | 6 | return URI->new_abs( | |||||||||
| 63 | $url, | ||||||||||
| 64 | $self->config->get('app_url', 'http://localhost:5000'), | ||||||||||
| 65 | )->as_string; | ||||||||||
| 66 | } | ||||||||||
| 67 | |||||||||||
| 68 | 3 | ▶ | sub abs_url_for ($self, $name, @args) | ||||||||
|
Subroutine
abs_url_for: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 69 | { | ||||||||||
| 70 | 3 | return $self->abs_url($self->url_for($name, @args)); | |||||||||
| 71 | } | ||||||||||
| 72 | |||||||||||
| 73 | 18 | ▶ | sub render_error ($self, $ctx, $code, $message = undef) | ||||||||
|
Subroutine
render_error: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 74 | 18 | { | |||||||||
| 75 | 18 | $self->app->render_error($self, $ctx, $code, $message); | |||||||||
| 76 | } | ||||||||||
| 77 | |||||||||||
| 78 | 56 | ▶ | sub render_response ($self, $ctx, $result) | ||||||||
|
Subroutine
render_response: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 79 | { | ||||||||||
| 80 | 56 | $self->app->render_response($self, $ctx, $result); | |||||||||
| 81 | } | ||||||||||
| 82 | |||||||||||
| 83 | ##################### | ||||||||||
| 84 | ### HOOKS SECTION ### | ||||||||||
| 85 | ##################### | ||||||||||
| 86 | |||||||||||
| 87 | 19 | ▶ | sub _on_error ($self, @args) | ||||||||
|
Subroutine
_on_error: called CC=1 SCAR=0.0
| |||||||||||
| 88 | { | ||||||||||
| 89 | 19 | $self->app->_fire_hooks(error => $self, @args); | |||||||||
| 90 | 19 | return $self->on_error(@args); | |||||||||
| 91 | } | ||||||||||
| 92 | |||||||||||
| 93 | 18 | ▶ | sub on_error ($self, $ctx, $error) | ||||||||
|
Subroutine
on_error: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 94 | { | ||||||||||
| 95 | 18 | return $self->app->on_error($self, $ctx, $error); | |||||||||
| 96 | } | ||||||||||
| 97 | |||||||||||
| 98 | __END__ | ||||||||||