File Coverage

blib/lib/Moonshine/Bootstrap/Component/MediaList.pm
Criterion Covered Total %
statement 14 14 100.0
branch n/a
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::MediaList;
2              
3 5     5   242258 use Moonshine::Magic;
  5         173742  
  5         44  
4              
5 5     5   3188 use Params::Validate qw/ARRAYREF/;
  5         13  
  5         462  
6              
7             extends (
8             'Moonshine::Bootstrap::Component',
9             'Moonshine::Bootstrap::Component::Media',
10             );
11              
12             has(
13             media_list_spec => sub {
14             {
15             tag => { default => 'ul' },
16             class_base => { default => 'media-list' },
17             media_items => { type => ARRAYREF, optional => 1 },
18             };
19             }
20             );
21              
22             sub media_list {
23 3     3   19474 my ($self) = shift;
24              
25 3   50     39 my ( $base_args, $build_args ) = $self->validate_build(
26             {
27             params => $_[0] // {},
28             spec => $self->media_list_spec,
29             }
30             );
31              
32 3         50 my $base_element = Moonshine::Element->new($base_args);
33              
34 3         8920 for ( @{ $build_args->{media_items} } ) {
  3         23  
35             $base_element->add_child(
36 3         10 $self->media( { tag => 'li', %{$_} } )
  3         72  
37             );
38             }
39              
40 3         8254 return $base_element;
41             }
42              
43             1;
44              
45             __END__