File Coverage

blib/lib/IBM/StorageSystem/Enclosure/Battery.pm
Criterion Covered Total %
statement 12 21 57.1
branch 0 4 0.0
condition n/a
subroutine 4 13 30.7
pod 0 1 0.0
total 16 39 41.0


line stmt bran cond sub pod time code
1             package IBM::StorageSystem::Enclosure::Battery;
2              
3 1     1   6 use strict;
  1         2  
  1         39  
4 1     1   6 use warnings;
  1         1  
  1         36  
5              
6 1     1   6 use Carp qw(croak);
  1         1  
  1         104  
7              
8             our $VERSION = '0.01';
9             our @ATTR = qw(FRU_identity FRU_part_number battery_id charging_status enclosure_id end_of_life_warning error_sequence_number firmware_level percent_charged recondition_needed status);
10              
11             foreach my $attr ( @ATTR ) {
12             {
13 1     1   5 no strict 'refs';
  1         1  
  1         239  
14             *{ __PACKAGE__ .'::'. $attr } = sub {
15 0     0     my( $self, $val ) = @_;
        0      
        0      
        0      
        0      
        0      
        0      
        0      
16 0 0         $self->{$attr} = $val if $val;
17 0           return $self->{$attr}
18             }
19             }
20             }
21              
22             sub new {
23 0     0 0   my( $class, $ibm, %args ) = @_;
24 0           my $self = bless {}, $class;
25 0 0         defined $args{battery_id} or croak 'Constructor failed: mandatory argument battery_id not supplied';
26              
27 0           foreach my $attr ( @ATTR ) { $self->{$attr} = $args{$attr} }
  0            
28              
29 0           return $self
30             }
31              
32             1;
33              
34             __END__