File Coverage

blib/lib/Moonshine/Bootstrap/Component/EmbedResponsive.pm
Criterion Covered Total %
statement 20 20 100.0
branch 2 2 100.0
condition 2 2 100.0
subroutine 6 6 100.0
pod n/a
total 30 30 100.0


line stmt bran cond sub pod time code
1             package Moonshine::Bootstrap::Component::EmbedResponsive;
2              
3 6     6   135885 use strict;
  6         15  
  6         246  
4 6     6   29 use warnings;
  6         13  
  6         334  
5              
6 6     6   376 use Moonshine::Magic;
  6         86760  
  6         42  
7 6     6   3410 use Moonshine::Bootstrap::Component;
  6         20  
  6         215  
8 6     6   59 use Moonshine::Util;
  6         20  
  6         49  
9              
10             extends 'Moonshine::Bootstrap::Component';
11              
12             has(
13             embed_responsive_spec => sub {
14             {
15             tag => { default => 'div' },
16             class_base => { default => 'embed-responsive' },
17             ratio => { optional => 1 },
18             ratio_base => { default => 'embed-responsive-' },
19             };
20             }
21             );
22              
23             sub embed_responsive {
24 8     8   18403 my ($self) = shift;
25              
26 8   100     73 my ( $base_args, $build_args ) = $self->validate_build(
27             {
28             params => $_[0] // {},
29             spec => $self->embed_responsive_spec,
30             }
31             );
32              
33 8 100       77 if ( my $ratio =
34             join_class( $build_args->{ratio_base}, $build_args->{ratio} ) )
35             {
36 2         20 $base_args->{class} = prepend_str( $ratio, $base_args->{class} );
37             }
38              
39 8         121 return Moonshine::Element->new($base_args);
40             }
41              
42             1;
43              
44             __END__