Hue/LightSet.pm untested

filter: Statementstmt 0.0% 0 / 40 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 61 CC 2 SCAR 10.3
CC
2
Cov
0%
AUTOLOAD
6.0
create
2.0
begin
2.0
CRAP 2.8
1 package Device::Hue::LightSet;
2 {
3 $Device::Hue::LightSet::VERSION = '0.4';
4 }
5  
6 use common::sense;
7 use Class::Accessor;
8  
9 use base qw(Class::Accessor);
10 use vars qw($AUTOLOAD);
11  
12 __PACKAGE__->mk_accessors( qw / _group _trx / );
13  
14 sub create
15 {
16 my ($self, @lights) = @_;
17  
18 $self = ref($self) || $self->new;
19  
20 $self->_group([ @lights ]);
21
22 return $self;
23 }
24  
25 sub begin
26 {
27 my ($self) = @_;
28  
29 $self->_trx(1);
30 do { $_->begin; } for @{$self->_group};
31 }
32  
33 sub commit
34 {
35 my ($self) = @_;
36  
37 do { $_->commit; } for @{$self->_group};
38 $self->_trx(0);
39 }
40  
41 sub in_transaction
42 {
43 return (shift)->_trx;
44 }
45  
46 sub AUTOLOAD
47 {
48 my ($self, @args) = @_;
49  
50 (my $method = $AUTOLOAD) =~ s/.*:://;
51  
52 return if $method eq 'DESTROY';
53  
54 foreach (@{$self->_group}) {
55 my $rc = $_->$method(@args);
56 }
57 }
58  
59 1;
60  
61 __END__