| 1 | package Gears::App; | ||
| 2 | 1 | $Gears::App::VERSION = '0.105'; | |
| 3 | 1 | ▶ | use v5.40; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 1 | ▶ | use Mooish::Base -standard; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | 1 | ▶ | use Gears qw(load_component get_component_name); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 1 | ▶ | use Gears::X; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | |||
| 9 | 1 | extends 'Gears::Component'; | |
| 10 | |||
| 11 | 1 | has param 'router' => ( | |
| 12 | isa => InstanceOf ['Gears::Router'], | ||
| 13 | ); | ||
| 14 | |||
| 15 | 1 | has param 'config' => ( | |
| 16 | isa => InstanceOf ['Gears::Config'], | ||
| 17 | ); | ||
| 18 | |||
| 19 | has field 'controllers' => ( | ||
| 20 | isa => ArrayRef [InstanceOf ['Gears::Controller']], | ||
| 21 | 1 | ▶ | default => sub { [] }, |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 22 | 1 | ); | |
| 23 | |||
| 24 | # we are the app | ||
| 25 | has extended 'app' => ( | ||
| 26 | 1 | ▶ | default => sub ($self) { $self }, |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 27 | 1 | init_arg => undef, | |
| 28 | ); | ||
| 29 | |||
| 30 | 3 | ▶ | sub _build_controller ($self, $class) |
|
Subroutine
_build_controller: called CC=1 SCAR=0.0
| |||
| 31 | { | ||
| 32 | 3 | return $class->new(app => $self); | |
| 33 | } | ||
| 34 | |||
| 35 | 3 | ▶ | sub load_controller ($self, $controller) |
|
Subroutine
load_controller: called CC=1 SCAR=0.0
Pod
documented
| |||
| 36 | { | ||
| 37 | 3 | my $base = (ref $self) . '::Controller'; | |
| 38 | 3 | my $class = get_component_name($controller, $base); | |
| 39 | 3 | push $self->controllers->@*, $self->_build_controller(load_component($class)); | |
| 40 | |||
| 41 | 3 | return $self; | |
| 42 | } | ||
| 43 | |||
| 44 | __END__ | ||