Slack/EventType.pm

filter: Statementstmt 75.6% 28 / 37 Branchbran 25.0% 3 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 77.7% 7 / 9 Podpod 0.0% 0 / 2 totaltotal 63.3% 38 / 60 CC 8 SCAR 28.1
CC
8
Cov
63%
from_json
42.0
__ANON__
2.0
import
2.0
CRAP 16.7
« Slack/Socket.pm ↑ Summary Slack/Commands.pm »
1 package Net::Async::Slack::EventType;
2  
3 106 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 106 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 106 our $VERSION = '0.015'; # VERSION
7  
8 106 ▶use Log::Any qw($log);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 106 ▶use Check::UnitCheck;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 106 our %REGISTERED_TYPES;
12  
13 795 ▶sub import {
Subroutine import: called CC=2 SCAR=6.9
14 795 my ($class, @args) = @_;
15 795 my ($pkg) = caller;
16  
17 # Bail out unless we're called directly, we don't want the import to propagate
18 # to subclasses.
19 795 ▶ return unless $class eq __PACKAGE__;
Branch: 1 branch
BranchTrueFalseTotal
unless $class eq __PACKAGE__ 394 401 795
20  
21 # Register and set up inheritance for things that import us directly,
22 # deferring the type registration until the module has been fully compiled.
23 401 ▶ Check::UnitCheck::unitcheckify(sub {
Subroutine __ANON__: called CC=2 SCAR=7.0
24 401 ▶ die 'Already registered ' . $pkg->type if exists $REGISTERED_TYPES{$pkg->type};
Branch: 1 branch
BranchTrueFalseTotal
if exists $Net::Async::Slack::EventType::REGISTERED_TYPES{$pkg->type} 0 401 401
25 401 $REGISTERED_TYPES{$pkg->type} = $pkg;
26 106 ▶ { no strict 'refs'; push @{$pkg . '::ISA'}, __PACKAGE__; }
Subroutine BEGIN: called CC=1 SCAR=0.0
27 401 }) ;
28 401 return;
29 }
30  
31 0 ▶sub from_json {
Subroutine from_json: not called CC=6 SCAR=37.4
Pod undocumented
32 0 my ($self, $data) = @_;
33 0 $log->tracef('Looking for type %s with available %s', $data->{type}, join ',', sort keys %REGISTERED_TYPES);
34 0 ▶ return undef unless my $class = $REGISTERED_TYPES{$data->{type}};
Branch: 1 branch
BranchTrueFalseTotal
unless my $class = $Net::Async::Slack::EventType::REGISTERED_TYPES{$data->{"type"}} 0 0 0
35 0 for (qw(user channel team source_team)) {
36 0 ▶ if(my $item = delete $data->{$_}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $item = delete $data->{$_}) 0 0 0
37 0 ▶ $data->{$_ . '_id'} = ref($item) ? $item->{id} : $item;
Branch: 1 branch
BranchTrueFalseTotal
ref $item ? : 0 0 0
38 0 ▶ $data->{$_} = $item if ref($item);
Branch: 1 branch
BranchTrueFalseTotal
if ref $item 0 0 0
39 }
40 }
41 0 return $class->new(%$data);
42 }
43  
44 0 ▶sub new { bless { @_[1..$#_] }, $_[0] }
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
45  
46 106 1;
47  
« Slack/Socket.pm ↑ Summary Slack/Commands.pm »