File Coverage

blib/lib/Connector/Proxy.pm
Criterion Covered Total %
statement 18 18 100.0
branch n/a
condition n/a
subroutine 6 6 100.0
pod n/a
total 24 24 100.0


line stmt bran cond sub pod time code
1             # Connector::Proxy
2             #
3             # Proxy class for attaching other CPAN modules
4             #
5             # Written by Scott Hardin and Martin Bartosch for the OpenXPKI project 2012
6             #
7              
8             use strict;
9 9     9   5020 use warnings;
  9         33  
  9         248  
10 9     9   45 use English;
  9         19  
  9         199  
11 9     9   56 use Moose;
  9         15  
  9         73  
12 9     9   3054 use Connector::Wrapper;
  9         18  
  9         49  
13 9     9   51750  
  9         26  
  9         1365  
14             extends 'Connector';
15              
16             has LOOPBACK => (
17             is => 'ro',
18             isa => 'Connector|Connector::Wrapper',
19             reader => 'conn',
20             required => 0,
21             );
22              
23             around BUILDARGS => sub {
24              
25             my $orig = shift;
26             my $class = shift;
27              
28             my $args = $_[0];
29              
30             if ( ref($args) eq 'HASH'
31             && defined($args->{CONNECTOR})
32             && defined($args->{TARGET}) ) {
33              
34             my %arg = %{$args};
35             $arg{'BASECONNECTOR'} = $arg{CONNECTOR};
36             delete $arg{CONNECTOR};
37              
38             $args->{LOOPBACK} = Connector::Wrapper->new( %arg );
39             }
40              
41             return $class->$orig(@_);
42              
43             };
44              
45             no Moose;
46 9     9   65 __PACKAGE__->meta->make_immutable;
  9         39  
  9         40  
47              
48             1;
49              
50             =head1 Name
51              
52             Connector
53              
54             =head1 Description
55              
56             This is the base class for all Connector::Proxy implementations.
57              
58             =head1 Developer Info
59              
60             When creating the connector, all class attributes that have a corresponding config
61             item are initialised with the given values.
62              
63             All configuration options, that are denoted on the same level as the connector
64             definition are accessible inside the class using C<$self->conn()->get()>.