File Coverage

blib/lib/IBM/StorageSystem/FileSystem/FileSet.pm
Criterion Covered Total %
statement 18 36 50.0
branch 0 10 0.0
condition n/a
subroutine 6 11 54.5
pod 0 1 0.0
total 24 58 41.3


line stmt bran cond sub pod time code
1             package IBM::StorageSystem::FileSystem::FileSet;
2              
3 1     1   219 use strict;
  1         3  
  1         48  
4 1     1   6 use warnings;
  1         2  
  1         29  
5              
6 1     1   5 use Scalar::Util qw(weaken);
  1         9  
  1         65  
7 1     1   6 use Carp qw(croak);
  1         2  
  1         160  
8              
9             our @ATTR = qw( Alloc_inodes Comment Creation_time Data ID device_name
10             Inode_space_owner Inodes Is_independent Max_inodes Name
11             Parent_id Path Root_inode Status Timestamp);
12              
13             our $OBJ = {
14             snapshot => {
15             cmd => 'lssnapshot -Y',
16             id => 'Snapshot_ID',
17             class => 'IBM::StorageSystem::Snapshot',
18             type => 'snapshot',
19             sl => 1
20             }
21             };
22              
23             foreach my $attr ( map lc, @ATTR ) {
24             {
25 1     1   12 no strict 'refs';
  1         2  
  1         111  
26             *{ __PACKAGE__ .'::'. $attr } =
27             sub {
28 0     0     my( $self, $val ) = @_;
29 0 0         $self->{$attr} = $val if $val;
30 0           return $self->{$attr}
31             }
32             }
33             }
34              
35             foreach my $obj ( keys %{ $OBJ } ) {
36             {
37 1     1   5 no strict 'refs';
  1         2  
  1         722  
38             my $m = 'get_'.$obj.'s';
39              
40             *{ __PACKAGE__ ."::$obj" } =
41             sub {
42 0     0     my( $self, $id ) = @_;
43 0 0         defined $id or return;
44              
45 0 0         return ( $self->{$obj}->{$id} ? $self->{$obj}->{$id}
46             : $self->$m( $id ) )
47             };
48              
49             *{ __PACKAGE__ .'::get_'. $obj } =
50             sub {
51 0     0     return $_[0]->$m( $_[1] )
52             };
53              
54             *{ __PACKAGE__ . "::$m" } =
55             sub {
56 0     0     my ( $self, $id ) = @_;
57 0           my %args = ( cmd => "$OBJ->{$obj}->{cmd} $self->{device_name} -j $self->{name} ",
58             class => $OBJ->{$obj}->{class},
59             type => $OBJ->{$obj}->{type},
60             id => $OBJ->{$obj}->{id}
61             );
62 0           my @res = $self->{__ibm}->__get_sl_objects( %args );
63            
64 0 0         return ( defined $id ? $self->{ $OBJ->{$obj}->{type} }->{$id}
65             : @res )
66             }
67             }
68             }
69              
70             sub new {
71 0     0 0   my( $class, $ibm, %args ) = @_;
72 0           my $self = bless {}, $class;
73 0 0         defined $args{ID} or croak 'Constructor failed: mandatory argument ID not supplied';
74 0           weaken( $self->{__ibm} = $ibm );
75              
76 0           foreach my $attr ( @ATTR ) {
77 0           $self->{lc $attr} = $args{$attr}
78             }
79              
80 0           return $self
81             }
82              
83             1;
84              
85             __END__