File Coverage

lib/Class/STL/ClassMembers/Disable.pm
Criterion Covered Total %
statement 74 87 85.0
branch 1 2 50.0
condition 1 3 33.3
subroutine 19 31 61.2
pod 0 1 0.0
total 95 124 76.6


line stmt bran cond sub pod time code
1             # vim:ts=4 sw=4
2             # ----------------------------------------------------------------------------------------------------
3             # Name : Class::STL::ClassMembers::Disable.pm
4             # Created : 8 May 2006
5             # Author : Mario Gaffiero (gaffie)
6             #
7             # Copyright 2006-2007 Mario Gaffiero.
8             #
9             # This file is part of Class::STL::Containers(TM).
10             #
11             # Class::STL::Containers is free software; you can redistribute it and/or modify
12             # it under the terms of the GNU General Public License as published by
13             # the Free Software Foundation; version 2 of the License.
14             #
15             # Class::STL::Containers is distributed in the hope that it will be useful,
16             # but WITHOUT ANY WARRANTY; without even the implied warranty of
17             # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18             # GNU General Public License for more details.
19             #
20             # You should have received a copy of the GNU General Public License
21             # along with Class::STL::Containers; if not, write to the Free Software
22             # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23             # ----------------------------------------------------------------------------------------------------
24             # Modification History
25             # When Version Who What
26             # ----------------------------------------------------------------------------------------------------
27             # TO DO:
28             # ----------------------------------------------------------------------------------------------------
29             require 5.005_62;
30 7     7   41 use strict;
  7         11  
  7         350  
31 7     7   39 use warnings;
  7         14  
  7         357  
32 7     7   38 use vars qw($VERSION $BUILD);
  7         14  
  7         649  
33             $VERSION = '0.21';
34             $BUILD = 'Monday May 8 23:08:34 GMT 2006';
35             # ----------------------------------------------------------------------------------------------------
36             {
37             package Class::STL::ClassMembers::Disable;
38 7     7   49 use Class::STL::ClassMembers qw( function_name _caller );
  7         16  
  7         68  
39 7     7   37 use Carp qw(confess);
  7         11  
  7         2974  
40             sub import
41             {
42 84     84   180 my $proto = shift;
43 84   33     394 my $class = ref($proto) || $proto;
44 84         160 my $self = {};
45 84         276 bless($self, $class);
46 84         3049 $self->_caller((caller())[0]);
47 84         2531 $self->function_name(shift);
48 7     7   49 eval($self->code());
  7     7   12  
  7     7   397  
  7     7   39  
  7     7   15  
  7     7   374  
  7     7   55  
  7     7   13  
  7     7   595  
  7     7   49  
  7     7   22  
  7     7   642  
  7     0   52  
  7     0   14  
  7     0   457  
  7     0   48  
  7     0   12  
  7     0   523  
  7     0   43  
  7     0   14  
  7     0   420  
  7     0   42  
  7     0   24  
  7     0   382  
  7         40  
  7         16  
  7         834  
  7         46  
  7         14  
  7         541  
  7         42  
  7         14  
  7         425  
  7         42  
  7         14  
  7         467  
  84         242  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
  0         0  
49 84 50       294 confess "**Error in eval for @{[ $self->_caller() ]} FunctionMemeber disable function creation:\n$@" if ($@);
  0         0  
50 84         8932 return $self;
51             }
52             sub code
53             {
54 84     84 0 113 my $self = shift;
55 84         130 my $tab = ' ' x 4;
56 84         99 my $code;
57 84         130 $code = "{\npackage @{[ $self->_caller() ]};\n";
  84         3605  
58 84         201 $code .= "sub @{[ $self->function_name() ]} {\n";
  84         2278  
59 84         212 $code .= "${tab}use Carp qw(confess);\n";
60 84         206 $code .= "${tab}confess \"Function '@{[ $self->function_name() ]}' not available for @{[ $self->_caller() ]}!\";\n";
  84         2588  
  84         2658  
61 84         234 $code .= "}\n";
62 84         204 $code .= "}\n";
63 84         9435 return $code;
64             }
65             }
66             # ----------------------------------------------------------------------------------------------------
67             1;