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   44 use strict;
  7         13  
  7         192  
31 7     7   33 use warnings;
  7         14  
  7         829  
32 7     7   39 use vars qw($VERSION $BUILD);
  7         13  
  7         568  
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   43 use Class::STL::ClassMembers qw( function_name _caller );
  7         14  
  7         38  
39 7     7   40 use Carp qw(confess);
  7         13  
  7         1929  
40             sub import
41             {
42 84     84   174 my $proto = shift;
43 84   33     314 my $class = ref($proto) || $proto;
44 84         158 my $self = {};
45 84         166 bless($self, $class);
46 84         2256 $self->_caller((caller())[0]);
47 84         1749 $self->function_name(shift);
48 7     7   43 eval($self->code());
  7     7   21  
  7     7   330  
  7     7   42  
  7     7   25  
  7     7   362  
  7     7   39  
  7     7   13  
  7     7   400  
  7     7   48  
  7     7   28  
  7     7   426  
  7     0   41  
  7     0   13  
  7     0   343  
  7     0   44  
  7     0   14  
  7     0   417  
  7     0   59  
  7     0   25  
  7     0   325  
  7     0   40  
  7     0   17  
  7     0   335  
  7         45  
  7         14  
  7         401  
  7         61  
  7         17  
  7         398  
  7         47  
  7         16  
  7         332  
  7         47  
  7         15  
  7         359  
  84         197  
  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       275 confess "**Error in eval for @{[ $self->_caller() ]} FunctionMemeber disable function creation:\n$@" if ($@);
  0         0  
50 84         7373 return $self;
51             }
52             sub code
53             {
54 84     84 0 137 my $self = shift;
55 84         134 my $tab = ' ' x 4;
56 84         111 my $code;
57 84         131 $code = "{\npackage @{[ $self->_caller() ]};\n";
  84         1682  
58 84         202 $code .= "sub @{[ $self->function_name() ]} {\n";
  84         1686  
59 84         266 $code .= "${tab}use Carp qw(confess);\n";
60 84         162 $code .= "${tab}confess \"Function '@{[ $self->function_name() ]}' not available for @{[ $self->_caller() ]}!\";\n";
  84         1688  
  84         1706  
61 84         199 $code .= "}\n";
62 84         127 $code .= "}\n";
63 84         6105 return $code;
64             }
65             }
66             # ----------------------------------------------------------------------------------------------------
67             1;