App/Role/HasComponents.pm untested

filter: Statementstmt 0.0% 0 / 27 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 41 CC 2 SCAR 11.5
CC
2
Cov
0%
register_component
6.0
BEGIN
2.0
BEGIN
2.0
CRAP 3.1
1 package Gapp::App::Role::HasComponents;
2 {
3 $Gapp::App::Role::HasComponents::VERSION = '0.007';
4 }
5  
6 use Moose::Role;
7 use MooseX::SemiAffordanceAccessor;
8 use MooseX::StrictConstructor;
9  
10 use Gapp::App::Hook;
11  
12 use MooseX::Types::Moose qw( Str Object );
13  
14 has '_components' => (
15 is => 'ro',
16 isa => 'HashRef',
17 traits => [qw( Hash )],
18 default => sub { { } },
19 handles => {
20 com => 'get',
21 },
22 lazy => 1,
23 );
24  
25  
26 sub register_component {
27 my ( $self, $name, $com ) = @_;
28
29 $self->meta->throw_error( 'usage $app->register_component( $name, $com )' ) if ! $name || ! $com;
30
31 $com->set_app( $self );
32
33 $com->register;
34
35 $self->_components->{ $name } = $com;
36
37 return $com;
38 }
39  
40  
41 1;
42  
43 __END__