File Coverage

blib/lib/Moonshine/Bootstrap/Component/Panel.pm
Criterion Covered Total %
statement 14 14 100.0
branch 2 2 100.0
condition 1 2 50.0
subroutine 3 3 100.0
pod n/a
total 20 21 95.2


line stmt bran cond sub pod time code
1             package Moonshine::Bootstrap::Component::Panel;
2              
3 5     5   227073 use Moonshine::Magic;
  5         132522  
  5         40  
4 5     5   2642 use Params::Validate qw/HASHREF/;
  5         12  
  5         508  
5              
6             extends (
7             'Moonshine::Bootstrap::Component',
8             'Moonshine::Bootstrap::Component::PanelHeader',
9             'Moonshine::Bootstrap::Component::PanelBody',
10             'Moonshine::Bootstrap::Component::PanelFooter',
11             );
12              
13             has(
14             panel_spec => sub {
15             {
16             tag => { default => 'div' },
17             class_base => { default => 'panel' },
18             switch => { default => 'default' },
19             switch_base => { default => 'panel-' },
20             header => { optional => 1, type => HASHREF },
21             body => { optional => 1, type => HASHREF },
22             footer => { optional => 1, type => HASHREF },
23             };
24             }
25             );
26              
27             sub panel {
28 9     9   69176 my ($self) = shift;
29              
30 9   50     83 my ( $base_args, $build_args ) = $self->validate_build(
31             {
32             params => $_[0] // {},
33             spec => $self->panel_spec,
34             }
35             );
36              
37 9         139 my $base_element = Moonshine::Element->new($base_args);
38              
39 9         23283 for (qw/header body footer/) {
40 27 100       17896 if ( $build_args->{$_} ) {
41 14         38 my $action = sprintf 'panel_%s', $_;
42 14         128 $base_element->add_child($self->$action($build_args->{$_}));
43             }
44             }
45              
46 9         96 return $base_element;
47             }
48              
49             1;
50              
51             __END__