File Coverage

blib/lib/LINE/Bot/API/Event/Things.pm
Criterion Covered Total %
statement 28 32 87.5
branch 1 2 50.0
condition n/a
subroutine 12 14 85.7
pod 0 6 0.0
total 41 54 75.9


line stmt bran cond sub pod time code
1             package LINE::Bot::API::Event::Things;
2 47     47   311 use strict;
  47         90  
  47         1319  
3 47     47   230 use warnings;
  47         82  
  47         1158  
4 47     47   258 use parent 'LINE::Bot::API::Event::Base';
  47         110  
  47         246  
5              
6 47     47   2764 use Carp 'carp';
  47         102  
  47         12946  
7             our @CARP_NOT = qw( LINE::Bot::API::Event::Things LINE::Bot::API::Event LINE::Bot::API);
8              
9             my %TYPE2CLASS = (
10             link => 'LINE::Bot::API::Event::Things::Link',
11             unlink => 'LINE::Bot::API::Event::Things::Unlink',
12             );
13              
14             sub new {
15 4     4 0 15 my($class, %args) = @_;
16              
17 4         17 my $type = $args{things}{type};
18 4         9 my $things_class = $TYPE2CLASS{$type};
19 4 50       11 unless ($things_class) {
20 0         0 carp 'Unsupported Things type: ' . $type;
21 0         0 $things_class = $class;
22             }
23              
24 4         26 bless { %args }, $things_class;
25             }
26              
27 2     2 0 7331 sub is_things_event { 1 }
28              
29 2     2 0 22 sub things_device_id { $_[0]->{things}{deviceId} }
30 2     2 0 10 sub things_type { $_[0]->{things}{type} }
31              
32 0     0 0 0 sub is_device_link { 0 }
33 0     0 0 0 sub is_device_unlink { 0 }
34              
35             package LINE::Bot::API::Event::Things::Link {
36 47     47   387 use parent 'LINE::Bot::API::Event::Things';
  47         120  
  47         295  
37              
38 1     1   5 sub is_device_link { 1 }
39             }
40              
41             package LINE::Bot::API::Event::Things::Unlink {
42 47     47   4538 use parent 'LINE::Bot::API::Event::Things';
  47         109  
  47         232  
43              
44 1     1   4 sub is_device_unlink { 1 }
45             }
46              
47             1;