Core/Handler/CommandHandler/GetTypeHandler.pm untested

filter: Statementstmt 0.0% 0 / 41 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 10 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 55 CC 2 SCAR 10.0
CC
2
Cov
0%
process
6.0
new
2.0
BEGIN
2.0
CRAP 2.7
1 package Javonet::Core::Handler::CommandHandler::GetTypeHandler;
2 use strict;
3 use warnings FATAL => 'all';
4 use lib 'lib';
5 use Moose;
6 use Nice::Try;
7 use aliased 'Javonet::Core::Exception::Exception' => 'Exception';
8 extends 'Javonet::Core::Handler::CommandHandler::AbstractCommandHandler';
9
10 sub new {
11 my $class = shift;
12 my $self = {
13 required_parameters_count => 1
14 };
15 return bless $self, $class;
16 }
17
18 sub process {
19 my ($self, $command) = @_;
20 try {
21 my $current_payload_ref = $command->{payload};
22 my @cur_payload = @$current_payload_ref;
23 my $parameters_length = @cur_payload;
24 if ($parameters_length != $self->{required_parameters_count}) {
25 die Exception->new("Exception: GetTypeHandler parameters mismatch");
26 }
27 my $class_name = $command->{payload}[0];
28
29 no strict 'refs';
30 eval("use $class_name;");
31 my $var = ${class_name};
32 return $var;
33 }
34 catch ($e){
35 return Exception->new($e);
36 }
37 }
38
39 no Moose;
40 1;