File Coverage

blib/lib/Moonshine/Bootstrap/Component/ListedGroupItem.pm
Criterion Covered Total %
statement 15 15 100.0
branch 4 4 100.0
condition 1 2 50.0
subroutine 3 3 100.0
pod n/a
total 23 24 95.8


line stmt bran cond sub pod time code
1             package Moonshine::Bootstrap::Component::ListedGroupItem;
2              
3 6     6   202083 use Moonshine::Magic;
  6         120179  
  6         44  
4 6     6   3068 use Params::Validate qw/HASHREF/;
  6         15  
  6         469  
5              
6             extends (
7             'Moonshine::Bootstrap::Component',
8             'Moonshine::Bootstrap::Component::Badge',
9             'Moonshine::Bootstrap::Component::ListedGroupItemText',
10             'Moonshine::Bootstrap::Component::ListedGroupItemHeading',
11             );
12              
13             has(
14             listed_group_item_spec => sub {
15             {
16             tag => { default => 'a' },
17             class_base => { default => 'list-group-item' },
18             switch_base => { default => 'list-group-item-' },
19             button => 0,
20             badge => { type => HASHREF, optional => 1 },
21             };
22             }
23             );
24              
25             sub listed_group_item {
26 20     20   92588 my ($self) = shift;
27              
28 20   50     238 my ( $base_args, $build_args ) = $self->validate_build(
29             {
30             params => $_[0] // {},
31             spec => $self->listed_group_item_spec,
32             }
33             );
34              
35 20 100       256 if ( $build_args->{button} ) {
36 6         21 $base_args->{tag} = 'button';
37 6         48 $base_args->{type} = 'button';
38             }
39              
40 20         150 my $base_element = Moonshine::Element->new($base_args);
41              
42 20 100       49058 if ( my $badge = $build_args->{badge} ) {
43 2         29 $base_element->add_child( $self->badge($badge) );
44             }
45              
46 20         256 return $base_element;
47             }
48              
49             1;
50              
51             __END__