File Coverage

blib/lib/Moonshine/Bootstrap/Component/Breadcrumb.pm
Criterion Covered Total %
statement 15 15 100.0
branch 2 2 100.0
condition 1 2 50.0
subroutine 3 3 100.0
pod n/a
total 21 22 95.4


line stmt bran cond sub pod time code
1             package Moonshine::Bootstrap::Component::Breadcrumb;
2              
3 5     5   203717 use Moonshine::Magic;
  5         130452  
  5         37  
4 5     5   2910 use Params::Validate qw/ARRAYREF/;
  5         12  
  5         434  
5              
6             lazy_components qw/li/;
7              
8             extends (
9             'Moonshine::Bootstrap::Component',
10             'Moonshine::Bootstrap::Component::LinkedLi',
11             );
12              
13             has(
14             breadcrumb_spec => sub {
15             {
16             tag => { default => 'ol' },
17             class_base => { default => 'breadcrumb' },
18             crumbs => { type => ARRAYREF },
19             };
20             }
21             );
22              
23             sub breadcrumb {
24 3     3   12774 my ($self) = shift;
25              
26 3   50     50 my ( $base_args, $build_args ) = $self->validate_build(
27             {
28             params => $_[0] // {},
29             spec => $self->breadcrumb_spec,
30             }
31             );
32              
33 3         61 my $base_element = Moonshine::Element->new($base_args);
34              
35 3         8068 for ( @{ $build_args->{crumbs} } ) {
  3         14  
36 9 100       189 if ( $_->{active} ) {
37 3         22 $base_element->add_child( $self->li($_) );
38             }
39             else {
40 6         52 $base_element->add_child( $self->linked_li($_) );
41             }
42             }
43              
44 3         6304 return $base_element;
45             }
46              
47             1;
48              
49             __END__