File Coverage

blib/lib/Gears/App.pm
Criterion Covered Total %
statement 24 24 100.0
branch n/a
condition n/a
subroutine 6 6 100.0
pod 1 1 100.0
total 31 31 100.0


line stmt bran cond sub pod time code
1             package Gears::App;
2             $Gears::App::VERSION = '0.101';
3 1     1   255042 use v5.40;
  1         5  
4 1     1   609 use Mooish::Base -standard;
  1         96556  
  1         11  
5              
6 1     1   337832 use Gears qw(load_component get_component_name);
  1         4  
  1         93  
7 1     1   599 use Gears::X;
  1         6  
  1         295  
8              
9             extends 'Gears::Component';
10              
11             has param 'router' => (
12             isa => InstanceOf ['Gears::Router'],
13             );
14              
15             has param 'config' => (
16             isa => InstanceOf ['Gears::Config'],
17             );
18              
19             has field 'controllers' => (
20             isa => ArrayRef [InstanceOf ['Gears::Controller']],
21             default => sub { [] },
22             );
23              
24             # we are the app
25             has extended 'app' => (
26             default => sub ($self) { $self },
27             init_arg => undef,
28             );
29              
30 3         3 sub _build_controller ($self, $class)
31 3     3   3 {
  3         3  
  3         3  
32 3         34 return $class->new(app => $self);
33             }
34              
35 3         2 sub load_controller ($self, $controller)
36 3     3 1 2770 {
  3         5  
  3         4  
37 3         4 my $base = (ref $self) . '::Controller';
38 3         8 my $class = get_component_name($controller, $base);
39 3         14 push $self->controllers->@*, $self->_build_controller(load_component($class));
40              
41 3         18 return $self;
42             }
43              
44             __END__