File Coverage

blib/lib/Net/Cisco/ObjectGroup/Protocol.pm
Criterion Covered Total %
statement 22 22 100.0
branch 10 10 100.0
condition 13 15 86.6
subroutine 5 5 100.0
pod 0 1 0.0
total 50 53 94.3


line stmt bran cond sub pod time code
1             package Net::Cisco::ObjectGroup::Protocol;
2 2     2   12 use base qw(Net::Cisco::ObjectGroup::Base);
  2         4  
  2         697  
3              
4 2     2   10 use strict;
  2         2  
  2         67  
5 2     2   9 use warnings FATAL => qw(all);
  2         4  
  2         77  
6              
7 2     2   24 use Carp;
  2         6  
  2         503  
8              
9             sub push {
10 6     6 0 2711 my $self = shift;
11 6         8 my $arg_ref = shift;
12              
13 6 100 66     241 croak 'must specify either group-object or protocol'
14             if !defined $arg_ref->{group_object}
15             and !defined $arg_ref->{protocol};
16              
17 5 100 100     185 croak 'cannot specify both group-object and protocol'
18             if defined $arg_ref->{group_object}
19             and defined $arg_ref->{protocol};
20              
21 4 100 100     217 croak 'bad group-object'
22             if defined $arg_ref->{group_object}
23             and ! UNIVERSAL::isa( $arg_ref->{group_object}, __PACKAGE__ );
24              
25              
26 3 100 66     14 $arg_ref->{protocol}
      100        
27             = __PACKAGE__->__dict->{$arg_ref->{protocol}}
28             if defined $arg_ref->{protocol}
29             and defined __PACKAGE__->__dict
30             and exists __PACKAGE__->__dict->{$arg_ref->{protocol}};
31              
32 3 100       53 my $line = defined $arg_ref->{protocol}
33             ? "protocol-object $arg_ref->{protocol}"
34             : 'group-object '. $arg_ref->{group_object}->get_name;
35              
36 3         8 push @{$self->get_objs}, $line;
  3         12  
37              
38 3         34 return $self;
39             }
40              
41             1;
42              
43             # Copyright (c) The University of Oxford 2006. All Rights Reserved.
44             #
45             # This program is free software; you can redistribute it and/or modify it
46             # under the terms of version 2 of the GNU General Public License as published
47             # by the Free Software Foundation.
48             #
49             # This program is distributed in the hope that it will be useful, but WITHOUT
50             # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
51             # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
52             # more details.
53             #
54             # You should have received a copy of the GNU General Public License along with
55             # this program; if not, write to the Free Software Foundation, Inc., 51
56             # Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
57              
58             __DATA__