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.021003';
3 5     5   14998 use strictures 2;
  5         1154  
  5         180  
4 5     5   761 use Carp;
  5         9  
  5         290  
5              
6 5     5   352 use Bot::Cobalt::Common ':types';
  5         9  
  5         27  
7              
8              
9 5     5   630 use Moo;
  5         6504  
  5         48  
10             extends 'Bot::Cobalt::Conf::File';
11              
12              
13             sub context {
14 2     2 1 1653 my ($self, $context) = @_;
15 2 50       9 croak "context() requires a server context identifier"
16             unless defined $context;
17              
18 2         50 $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__