RWDE/Proxy.pm untested

filter: Statementstmt 0.0% 0 / 18 Branchbran n/a Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 29 CC 1 SCAR 6.9
CC
1
Cov
0%
invoke
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package RWDE::Proxy;
2  
3 use strict;
4 use warnings;
5  
6 use RWDE::AbstractFactory;
7  
8 use vars qw($VERSION);
9 $VERSION = sprintf "%d", q$Revision: 507 $ =~ /(\d+)/;
10  
11 =pod
12  
13 =head1 RWDE::Proxy
14  
15 Proxy object for getting the specific functionality of a particular object
16  
17 =cut
18  
19 =head2 invoke({ class => class_name, function => function_name, params => function_params})
20  
21 To avoid require, eval and invocation from within a block of code, which is suboptimal,
22 the proxy object instantiates the object, invokes the function with the given params hash and returns the result.
23  
24 =cut
25  
26 sub invoke {
27 my ($self,$params) = @_;
28  
29 my $function = $$params{'function'}
30 or throw RWDE::DevelException({ info => 'Proxy::Parameter error - function not specified'});
31  
32 my $term = RWDE::AbstractFactory->instantiate($params);
33  
34 return $term->$function($params);
35 }
36  
37 1;