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 81     81   7497 use strict;
  81         73  
  81         1851  
18 81     81   232 use warnings;
  81         68  
  81         1440  
19              
20 81     81   1145 use Net::DRI::Exception;
  81         70  
  81         3287  
21              
22             ####################################################################################################
23             ## CLASS METHODS
24              
25             sub make_exception_if_not_implemented
26             {
27 146     146 0 550 my ($self,@methods)=@_;
28 146   33     930 my $class=ref $self || $self;
29 146         370 foreach my $name (@methods)
30             {
31 81     81   261 no strict 'refs'; ## no critic (ProhibitNoStrict)
  81         67  
  81         9706  
32 663     0   1593 *{"${class}::${name}"}=sub { my $self=shift; Net::DRI::Exception->die(1,'internal',1,sprintf('Method %s not implemented in %s, please report.',$name,$class)); };
  663         2305  
  0         0  
  0         0  
33             }
34 146         377 return;
35             }
36              
37             sub make_exception_for_unavailable_operations
38             {
39 29     29 0 102 my ($self,@methods)=@_;
40 29   33     140 my $class=ref $self || $self;
41 29         60 foreach my $name (@methods)
42             {
43 281         404 my @op=split(/_/,$name,2);
44 81     81   275 no strict 'refs'; ## no critic (ProhibitNoStrict)
  81         74  
  81         5137  
45 281     0   520 *{"${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         890  
  0         0  
  0         0  
46             }
47 81     81   924 no strict 'refs'; ## no critic (ProhibitNoStrict)
  81         120  
  81         10682  
48 29     0   74 *{"${class}::unavailable_operations"}=sub { return @methods; };
  29         92  
  0         0  
49 29         69 return;
50             }
51              
52             ####################################################################################################
53             ## OBJECT METHODS
54              
55             sub generate_trid
56             {
57 10     10 0 11 my ($self,$name)=@_;
58 10 50       16 if (! defined $name) { $name=$self->name(); }
  10         20  
59 10         46 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         11  
  3         6  
63 512 50   512 0 947 sub log_output { my ($self,@r)=@_; $self->logging()->output(@r) if $self->logging(); return; }
  512         1332  
  512         886  
64              
65             ####################################################################################################
66             1;
67              
68             __END__