RWDE/Singleton.pm untested

filter: Statementstmt 0.0% 0 / 21 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 32 CC 2 SCAR 11.5
CC
2
Cov
0%
new
6.0
initialize
2.0
DESTROY
2.0
CRAP 3.1
1 # Singleton variables and functions
2 package RWDE::Singleton;
3  
4 use strict;
5 use warnings;
6  
7 use vars qw($VERSION);
8 $VERSION = sprintf "%d", q$Revision: 507 $ =~ /(\d+)/;
9  
10 sub new {
11 my ($class, $params) = @_;
12  
13 if (caller() ne $class) {
14 my ($package, $filename, $line) = caller();
15 throw RWDE::DevelException({ info => " ($package) from $filename Line: $line is trying to access the constructor directly. Use get_instance instead." });
16 }
17  
18 my $self = { _data => 'something' };
19  
20 bless($self, $class);
21  
22 $self->initialize($params);
23  
24 return $self;
25 }
26  
27 sub initialize {
28 my ($self, $params) = @_;
29  
30 return ();
31 }
32  
33 # do nothing. here just to shut up TT when AUTOLOAD is present
34 sub DESTROY {
35  
36 }
37  
38 1;