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 53     53   343 use strict;
  53         110  
  53         2256  
3 53     53   288 use warnings;
  53         89  
  53         2849  
4 53     53   305 use parent 'LINE::Bot::API::Event::Base';
  53         88  
  53         794  
5              
6 53     53   3720 use Carp 'carp';
  53         100  
  53         17445  
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 16 my($class, %args) = @_;
16              
17 4         8 my $type = $args{things}{type};
18 4         10 my $things_class = $TYPE2CLASS{$type};
19 4 50       10 unless ($things_class) {
20 0         0 carp 'Unsupported Things type: ' . $type;
21 0         0 $things_class = $class;
22             }
23              
24 4         28 bless { %args }, $things_class;
25             }
26              
27 2     2 0 11987 sub is_things_event { 1 }
28              
29 2     2 0 13 sub things_device_id { $_[0]->{things}{deviceId} }
30 2     2 0 14 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 53     53   452 use parent 'LINE::Bot::API::Event::Things';
  53         124  
  53         280  
37              
38 1     1   569 sub is_device_link { 1 }
39             }
40              
41             package LINE::Bot::API::Event::Things::Unlink {
42 53     53   6682 use parent 'LINE::Bot::API::Event::Things';
  53         162  
  53         246  
43              
44 1     1   620 sub is_device_unlink { 1 }
45             }
46              
47             1;