File Coverage

blib/lib/Bot/Cobalt/Conf/File/Channels.pm
Criterion Covered Total %
statement 15 15 100.0
branch 1 2 50.0
condition n/a
subroutine 5 5 100.0
pod 1 1 100.0
total 22 23 95.6


line stmt bran cond sub pod time code
1             package Bot::Cobalt::Conf::File::Channels;
2             $Bot::Cobalt::Conf::File::Channels::VERSION = '0.021002';
3 5     5   13156 use strictures 2;
  5         1090  
  5         171  
4 5     5   812 use Carp;
  5         5  
  5         287  
5              
6 5     5   342 use Bot::Cobalt::Common ':types';
  5         5  
  5         39  
7              
8              
9 5     5   439 use Moo;
  5         5718  
  5         26  
10             extends 'Bot::Cobalt::Conf::File';
11              
12              
13             sub context {
14 2     2 1 1551 my ($self, $context) = @_;
15 2 50       7 croak "context() requires a server context identifier"
16             unless defined $context;
17              
18 2         40 $self->cfg_as_hash->{$context}
19             }
20              
21              
22             around 'validate' => sub {
23             my ($orig, $self, $cfg) = @_;
24              
25             my @contexts = keys %$cfg;
26             die "There are no contexts defined.\n" unless @contexts;
27            
28             for my $context (@contexts) {
29             die "Context directive $context is not a hash"
30             unless ref $cfg->{$context} eq 'HASH';
31             }
32              
33             1
34             };
35              
36              
37             1;
38             __END__