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             package Connector::Proxy;
8              
9 9     9   5451 use strict;
  9         36  
  9         274  
10 9     9   47 use warnings;
  9         17  
  9         209  
11 9     9   48 use English;
  9         15  
  9         58  
12 9     9   3152 use Moose;
  9         35  
  9         61  
13 9     9   54147 use Connector::Wrapper;
  9         38  
  9         1484  
14              
15             extends 'Connector';
16              
17             has LOOPBACK => (
18             is => 'ro',
19             isa => 'Connector|Connector::Wrapper',
20             reader => 'conn',
21             required => 0,
22             );
23              
24             around BUILDARGS => sub {
25              
26             my $orig = shift;
27             my $class = shift;
28              
29             my $args = $_[0];
30              
31             if ( ref($args) eq 'HASH'
32             && defined($args->{CONNECTOR})
33             && defined($args->{TARGET}) ) {
34              
35             my %arg = %{$args};
36             $arg{'BASECONNECTOR'} = $arg{CONNECTOR};
37             delete $arg{CONNECTOR};
38              
39             $args->{LOOPBACK} = Connector::Wrapper->new( %arg );
40             }
41              
42             return $class->$orig(@_);
43              
44             };
45              
46 9     9   74 no Moose;
  9         39  
  9         51  
47             __PACKAGE__->meta->make_immutable;
48              
49             1;
50             __END__
51              
52             =head1 Name
53              
54             Connector
55              
56             =head1 Description
57              
58             This is the base class for all Connector::Proxy implementations.
59              
60             =head1 Developer Info
61              
62             When creating the connector, all class attributes that have a corresponding config
63             item are initialised with the given values.
64              
65             All configuration options, that are denoted on the same level as the connector
66             definition are accessible inside the class using C<$self->conn()->get()>.