File Coverage

blib/lib/Moonshine/Bootstrap/Component/ListGroupItem.pm
Criterion Covered Total %
statement 12 12 100.0
branch 2 2 100.0
condition 1 2 50.0
subroutine 3 3 100.0
pod n/a
total 18 19 94.7


line stmt bran cond sub pod time code
1             package Moonshine::Bootstrap::Component::ListGroupItem;
2              
3 6     6   231286 use Moonshine::Magic;
  6         166396  
  6         58  
4 6     6   3891 use Params::Validate qw/HASHREF/;
  6         20  
  6         579  
5              
6             extends (
7             'Moonshine::Bootstrap::Component',
8             'Moonshine::Bootstrap::Component::Badge',
9             );
10              
11             has(
12             list_group_item_spec => sub {
13             {
14             tag => { default => 'li' },
15             class_base => { default => 'list-group-item' },
16             switch_base => { default => 'list-group-item-' },
17             badge => { type => HASHREF, optional => 1 },
18             };
19             }
20             );
21              
22             sub list_group_item {
23 14     14   79090 my ($self) = shift;
24              
25 14   50     135 my ( $base_args, $build_args ) = $self->validate_build(
26             {
27             params => $_[0] // {},
28             spec => $self->list_group_item_spec,
29             }
30             );
31              
32 14         198 my $base_element = Moonshine::Element->new($base_args);
33              
34 14 100       37096 if ( my $badge = $build_args->{badge} ) {
35 5         57 $base_element->add_child( $self->badge($badge) );
36             }
37              
38 14         407 return $base_element;
39             }
40              
41             1;
42              
43             __END__