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   5879 use strict;
  9         35  
  9         295  
10 9     9   53 use warnings;
  9         20  
  9         246  
11 9     9   61 use English;
  9         19  
  9         68  
12 9     9   3638 use Moose;
  9         30  
  9         61  
13 9     9   62025 use Connector::Wrapper;
  9         36  
  9         1781  
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   86 no Moose;
  9         48  
  9         55  
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()>.