File Coverage

blib/lib/Cinnamon/Role.pm
Criterion Covered Total %
statement 19 19 100.0
branch 4 4 100.0
condition n/a
subroutine 6 6 100.0
pod 0 2 0.0
total 29 31 93.5


line stmt bran cond sub pod time code
1             package Cinnamon::Role;
2 4     4   108089 use strict;
  4         10  
  4         170  
3 4     4   23 use warnings;
  4         6  
  4         123  
4              
5 4     4   1032 use Moo;
  4         15421  
  4         33  
6 4     4   3559 use Hash::MultiValue;
  4         2374  
  4         672  
7              
8             has name => (is => 'ro', required => 1);
9             has hosts => (is => 'ro', required => 1);
10             has params => (is => 'ro', default => sub { Hash::MultiValue->new });
11              
12             sub get_hosts {
13 22     22 0 220 my ($self) = @_;
14 22         65 my $hosts = $self->hosts;
15 22 100       69 if (ref $hosts eq 'CODE') {
16 2         8 return $hosts->();
17             }
18 20 100       104 return ref $hosts eq 'ARRAY' ? $hosts : [$hosts];
19             }
20              
21             sub info {
22 1     1 0 3 my ($self) = @_;
23             return +{
24 1         5 hosts => $self->get_hosts,
25             params => $self->params->as_hashref,
26             };
27             }
28              
29             1;