File Coverage

blib/lib/Moonshine/Bootstrap/Component/MediaObject.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::MediaObject;
2              
3 7     7   196973 use Moonshine::Magic;
  7         131814  
  7         54  
4 7     7   4177 use Moonshine::Util;
  7         19  
  7         71  
5              
6             lazy_components(qw/h4/);
7              
8             extends (
9             'Moonshine::Bootstrap::Component',
10             'Moonshine::Bootstrap::Component::MediaLinkImage',
11             );
12              
13             has(
14             media_object_spec => sub {
15             {
16             tag => { default => 'div' },
17             x => 0,
18             y => 0,
19             base_class => { default => 'media-' },
20             body => 0,
21             };
22             }
23             );
24              
25             sub media_object {
26 17     17   54391 my ($self) = shift;
27              
28 17   50     168 my ( $base_args, $build_args ) = $self->validate_build(
29             {
30             params => $_[0] // {},
31             spec => $self->media_object_spec,
32             }
33             );
34              
35 17         195 my $base = $build_args->{base_class};
36 17 100       136 if ( $build_args->{body} ) {
37             $base_args->{class} = append_str(
38             join_class( $base, 'body'), $base_args->{class}
39 8         40 );
40             }
41            
42 17         188 for (qw/y x/) {
43 34 100       219 if ( my $class = join_class($base, $build_args->{$_}) ) {
44 18         182 $base_args->{class} = append_str($class, $base_args->{class});
45             }
46             }
47              
48 17         197 return Moonshine::Element->new($base_args);
49             }
50              
51             1;
52              
53             __END__