File Coverage

blib/lib/Moonshine/Bootstrap/Component/Badge.pm
Criterion Covered Total %
statement 14 14 100.0
branch 2 2 100.0
condition 1 2 50.0
subroutine 3 3 100.0
pod n/a
total 20 21 95.2


line stmt bran cond sub pod time code
1             package Moonshine::Bootstrap::Component::Badge;
2              
3 9     9   160071 use Moonshine::Magic;
  9         91690  
  9         73  
4              
5             extends 'Moonshine::Bootstrap::Component';
6 9     9   6995 use Params::Validate qw/HASHREF/;
  9         19  
  9         1159  
7              
8             has(
9             badge_spec => sub {
10             {
11             tag => { default => 'span' },
12             wrapper => { type => HASHREF, optional => 1 },
13             class_base => { default => 'badge' },
14             };
15             }
16             );
17              
18             sub badge {
19 12     12   31332 my ($self) = shift;
20              
21 12   50     117 my ( $base_args, $build_args ) = $self->validate_build(
22             {
23             params => $_[0] // {},
24             spec => $self->badge_spec,
25             }
26             );
27              
28 12         182 my $base_element = Moonshine::Element->new($base_args);
29              
30             #---------.....----....---..--....
31 12 100       34480 if ( defined $build_args->{wrapper} ) {
32 3         19 my $wrapper = Moonshine::Element->new( $build_args->{wrapper} );
33 3         11753 $wrapper->add_child($base_element);
34 3         160 return $wrapper;
35             }
36              
37 9         85 return $base_element;
38             }
39              
40             1;
41              
42             __END__