File Coverage

blib/lib/Net/DRI/BaseClass.pm
Criterion Covered Total %
statement 43 48 89.5
branch 2 4 50.0
condition 2 6 33.3
subroutine 11 14 78.5
pod 0 5 0.0
total 58 77 75.3


line stmt bran cond sub pod time code
1             ## Domain Registry Interface, Superclass of various classes for Net::DRI
2             ##
3             ## Copyright (c) 2009-2010,2013 Patrick Mevzek . All rights reserved.
4             ##
5             ## This file is part of Net::DRI
6             ##
7             ## Net::DRI is free software; you can redistribute it and/or modify
8             ## it under the terms of the GNU General Public License as published by
9             ## the Free Software Foundation; either version 2 of the License, or
10             ## (at your option) any later version.
11             ##
12             ## See the LICENSE file that comes with this distribution for more details.
13             ####################################################################################################
14              
15             package Net::DRI::BaseClass;
16              
17 72     72   8996 use strict;
  72         135  
  72         2681  
18 72     72   327 use warnings;
  72         101  
  72         1864  
19              
20 72     72   1521 use Net::DRI::Exception;
  72         107  
  72         4049  
21              
22             ####################################################################################################
23             ## CLASS METHODS
24              
25             sub make_exception_if_not_implemented
26             {
27 128     128 0 687 my ($self,@methods)=@_;
28 128   33     1268 my $class=ref $self || $self;
29 128         501 foreach my $name (@methods)
30             {
31 72     72   310 no strict 'refs'; ## no critic (ProhibitNoStrict)
  72         102  
  72         11752  
32 582     0   1830 *{"${class}::${name}"}=sub { my $self=shift; Net::DRI::Exception->die(1,'internal',1,sprintf('Method %s not implemented in %s, please report.',$name,$class)); };
  582         2849  
  0         0  
  0         0  
33             }
34 128         559 return;
35             }
36              
37             sub make_exception_for_unavailable_operations
38             {
39 29     29 0 113 my ($self,@methods)=@_;
40 29   33     177 my $class=ref $self || $self;
41 29         73 foreach my $name (@methods)
42             {
43 281         580 my @op=split(/_/,$name,2);
44 72     72   401 no strict 'refs'; ## no critic (ProhibitNoStrict)
  72         110  
  72         6823  
45 281     0   663 *{"${class}::${name}"}=sub { my $self=shift; Net::DRI::Exception->die(0,'DRD',4,sprintf('No operation %s %s available for registry %s',@op,$self->name())); };
  281         1148  
  0         0  
  0         0  
46             }
47 72     72   326 no strict 'refs'; ## no critic (ProhibitNoStrict)
  72         108  
  72         12598  
48 29     0   118 *{"${class}::unavailable_operations"}=sub { return @methods; };
  29         130  
  0         0  
49 29         90 return;
50             }
51              
52             ####################################################################################################
53             ## OBJECT METHODS
54              
55             sub generate_trid
56             {
57 10     10 0 17 my ($self,$name)=@_;
58 10 50       29 if (! defined $name) { $name=$self->name(); }
  10         31  
59 10         59 return $self->trid_factory()->($name);
60             }
61              
62 3     3 0 8 sub log_setup_channel { my ($self,@r)=@_; $self->logging()->setup_channel(@r); return; }
  3         17  
  3         7  
63 458 50   458 0 1088 sub log_output { my ($self,@r)=@_; $self->logging()->output(@r) if $self->logging(); return; }
  458         1391  
  458         915  
64              
65             ####################################################################################################
66             1;
67              
68             __END__