File Coverage

blib/lib/Moonshine/Bootstrap/Component/ListGroup.pm
Criterion Covered Total %
statement 13 13 100.0
branch n/a
condition 1 2 50.0
subroutine 3 3 100.0
pod n/a
total 17 18 94.4


line stmt bran cond sub pod time code
1             package Moonshine::Bootstrap::Component::ListGroup;
2              
3 5     5   301007 use Moonshine::Magic;
  5         140545  
  5         46  
4 5     5   3422 use Params::Validate qw/ARRAYREF/;
  5         15  
  5         504  
5              
6             extends (
7             'Moonshine::Bootstrap::Component',
8             'Moonshine::Bootstrap::Component::ListGroupItem',
9             );
10              
11             has(
12             list_group_spec => sub {
13             {
14             tag => { default => 'ul' },
15             class_base => { default => 'list-group' },
16             list_items => { type => ARRAYREF, default => [ ] },
17             };
18             }
19             );
20              
21             sub list_group {
22 3     3   9519 my ($self) = shift;
23              
24 3   50     30 my ( $base_args, $build_args ) = $self->validate_build(
25             {
26             params => $_[0] // {},
27             spec => $self->list_group_spec,
28             }
29             );
30              
31 3         67 my $base_element = Moonshine::Element->new($base_args);
32              
33 3         8289 for ( @{ $build_args->{list_items} } ) {
  3         17  
34 3         35 $base_element->add_child($self->list_group_item($_));
35             }
36              
37 3         181 return $base_element;
38             }
39              
40             1;
41              
42             __END__