| 1 | package IBM::StorageSystem::EnclosureBattery; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | |||
| 6 | use Carp qw(croak); | ||
| 7 | |||
| 8 | our @ATTR = qw(enclosure_id:battery_id enclosure_id battery_id status charging_status recondition_needed percent_charged end_of_life_warning); | ||
| 9 | |||
| 10 | foreach my $attr ( @ATTR ) { | ||
| 11 | { | ||
| 12 | no strict 'refs'; | ||
| 13 | *{ __PACKAGE__ .'::'. $attr } = sub { | ||
| 14 | my( $self, $val ) = @_; | ||
| 15 | $self->{$attr} = $val if $val; | ||
| 16 | return $self->{$attr} | ||
| 17 | } | ||
| 18 | } | ||
| 19 | } | ||
| 20 | |||
| 21 | sub new { | ||
| 22 | my( $class, %args ) = @_; | ||
| 23 | my $self = bless {}, $class; | ||
| 24 | defined $args{'enclosure_id:battery_id'} or croak __PACKAGE__ . ' constructor failed: mandatory enclosure_id:battery_id argument not supplied'; | ||
| 25 | |||
| 26 | foreach my $attr ( @ATTR ) { $self->{$attr} = $args{$attr} } | ||
| 27 | |||
| 28 | return $self | ||
| 29 | } | ||
| 30 | |||
| 31 | 1; | ||
| 32 |