File Coverage

blib/lib/Bot/Cobalt/IRC/Event/Mode.pm
Criterion Covered Total %
statement 18 18 100.0
branch n/a
condition n/a
subroutine 6 6 100.0
pod n/a
total 24 24 100.0


line stmt bran cond sub pod time code
1             package Bot::Cobalt::IRC::Event::Mode;
2             $Bot::Cobalt::IRC::Event::Mode::VERSION = '0.021003';
3 6     6   16026 use strictures 2;
  6         1280  
  6         225  
4              
5 6     6   1149 use Bot::Cobalt;
  6         9  
  6         35  
6 6     6   4157 use Bot::Cobalt::Common qw/:types/;
  6         9  
  6         30  
7              
8 6     6   31 use IRC::Utils qw/parse_mode_line eq_irc/;
  6         9  
  6         362  
9              
10 6     6   600 use Moo;
  6         7038  
  6         114  
11             extends 'Bot::Cobalt::IRC::Event';
12              
13             has mode => (
14             required => 1,
15             is => 'rw',
16             isa => Str,
17             );
18              
19             has target => (
20             required => 1,
21             is => 'rw',
22             isa => Str,
23             );
24              
25             has is_umode => (
26             lazy => 1,
27             is => 'ro',
28             isa => Bool,
29             default => sub {
30             my ($self) = @_;
31             my $casemap = core->get_irc_casemap( $self->context );
32             my $irc_obj = core->get_irc_object( $self->context );
33             eq_irc($irc_obj->nick_name, $self->target)
34             },
35             );
36              
37             has channel => (
38             lazy => 1,
39             is => 'rw',
40             default => sub {
41             my ($self) = @_;
42             $self->is_umode ? undef : $self->target
43             },
44             );
45              
46             has args => (
47             lazy => 1,
48             is => 'rw',
49             isa => ArrayObj,
50             coerce => 1,
51             default => sub { [] },
52             );
53              
54             has hash => (
55             lazy => 1,
56             is => 'ro',
57             isa => HashObj,
58             coerce => 1,
59             predicate => 'has_hash',
60             builder => '_build_hash',
61             );
62              
63             sub _build_hash {
64 1     1   957 my ($self) = @_;
65 1         17 parse_mode_line( $self->mode, @{ $self->args })
  1         8  
66             }
67              
68             1;
69             __END__