File Coverage

blib/lib/AquariumHive/State.pm
Criterion Covered Total %
statement 4 11 36.3
branch 0 2 0.0
condition n/a
subroutine 2 4 50.0
pod 0 2 0.0
total 6 19 31.5


line stmt bran cond sub pod time code
1             package AquariumHive::State;
2             BEGIN {
3 1     1   28 $AquariumHive::State::AUTHORITY = 'cpan:GETTY';
4             }
5             $AquariumHive::State::VERSION = '0.002';
6 1     1   4 use Moo;
  1         2  
  1         11  
7              
8             our @attributes;
9              
10             for my $pwm_no (1..6) {
11             my $pwm = 'pwm'.$pwm_no;
12             push @attributes, $pwm;
13             has $pwm, (
14             is => 'rw',
15             );
16             }
17              
18             for my $sensor_row (1..2) {
19             for my $sensor (qw( temp ph orp ec )) {
20             my $attr = $sensor.$sensor_row;
21             push @attributes, $attr;
22             has $attr, (
23             is => 'rw',
24             );
25             }
26             }
27              
28             sub data {
29 0     0 0   my ( $self ) = @_;
30 0           return {map {
31 0           $_, $self->$_()
32             } @attributes};
33             }
34              
35             sub update {
36 0     0 0   my ( $self, $data ) = @_;
37 0           for (@attributes) {
38 0 0         $self->$_($data->{$_}) if defined $data->{$_};
39             }
40 0           return $self;
41             }
42              
43             1;
44              
45             __END__
46              
47             =pod
48              
49             =head1 NAME
50              
51             AquariumHive::State
52              
53             =head1 VERSION
54              
55             version 0.002
56              
57             =head1 DESCRIPTION
58              
59             B<IN DEVELOPMENT, DO NOT USE YET>
60              
61             See L<http://aquariumhive.com/> for now.
62              
63             =head1 SUPPORT
64              
65             IRC
66              
67             Join #AquariumHive on irc.freenode.net. Highlight Getty for fast reaction :).
68              
69             Repository
70              
71             https://github.com/homehivelab/aquariumhive
72             Pull request and additional contributors are welcome
73              
74             Issue Tracker
75              
76             https://github.com/homehivelab/aquariumhive/issues
77              
78             =head1 AUTHOR
79              
80             Torsten Raudssus <torsten@raudss.us>
81              
82             =head1 COPYRIGHT AND LICENSE
83              
84             This software is copyright (c) 2014 by Torsten Raudssus.
85              
86             This is free software; you can redistribute it and/or modify it under
87             the same terms as the Perl 5 programming language system itself.
88              
89             =cut