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 51     51   339 use strict;
  51         125  
  51         1511  
3 51     51   247 use warnings;
  51         100  
  51         1294  
4 51     51   244 use parent 'LINE::Bot::API::Event::Base';
  51         142  
  51         260  
5              
6 51     51   2976 use Carp 'carp';
  51         101  
  51         15242  
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         10 my $type = $args{things}{type};
18 4         10 my $things_class = $TYPE2CLASS{$type};
19 4 50       16 unless ($things_class) {
20 0         0 carp 'Unsupported Things type: ' . $type;
21 0         0 $things_class = $class;
22             }
23              
24 4         27 bless { %args }, $things_class;
25             }
26              
27 2     2 0 9832 sub is_things_event { 1 }
28              
29 2     2 0 31 sub things_device_id { $_[0]->{things}{deviceId} }
30 2     2 0 12 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 51     51   415 use parent 'LINE::Bot::API::Event::Things';
  51         114  
  51         323  
37              
38 1     1   5 sub is_device_link { 1 }
39             }
40              
41             package LINE::Bot::API::Event::Things::Unlink {
42 51     51   5368 use parent 'LINE::Bot::API::Event::Things';
  51         139  
  51         213  
43              
44 1     1   5 sub is_device_unlink { 1 }
45             }
46              
47             1;