| 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
| |||||||||||
| 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
| |||||||||||
| 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
| |||||||||||
| 35 | 0 | for (qw(user channel team source_team)) { | |||||||||
| 36 | 0 | ▶ | if(my $item = delete $data->{$_}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 37 | 0 | ▶ | $data->{$_ . '_id'} = ref($item) ? $item->{id} : $item; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 38 | 0 | ▶ | $data->{$_} = $item if ref($item); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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 | |||||||||||