diff Lib/IMPL/Serialization.pm @ 198:2ffe6f661605

Implemented IMPL::Web::Handler::RestController fixes in IMPL::Serialization completed IMPL::Web::Application::RestResource added IMPL::Web::Handler::JSONView added IMPL::Web::RestContract
author cin
date Fri, 20 Apr 2012 16:06:36 +0400
parents a705e848dcc7
children e743a8481327
line wrap: on
line diff
--- a/Lib/IMPL/Serialization.pm	Thu Apr 19 02:10:02 2012 +0400
+++ b/Lib/IMPL/Serialization.pm	Fri Apr 20 16:06:36 2012 +0400
@@ -242,7 +242,7 @@
       return 1;
     }
     
-    my $refObj = $this->{$ObjectFactory} ?$this->{$ObjectFactory}->($rhObject->{'Type'},$rhObject->{'Data'},$rhObject->{'Id'} ? $this->{$Context}->{$rhObject->{'Id'}} : undef) : DefaultFactory($rhObject->{'Type'},$rhObject->{'Data'},$rhObject->{'Id'} ? $this->{$Context}->{$rhObject->{'Id'}} : undef);
+    my $refObj = $this->{$ObjectFactory} ?$this->{$ObjectFactory}->($rhObject->{'Type'},$rhObject->{'Data'},$rhObject->{'Id'} ? $this->{$Context}->{$rhObject->{'Id'}} : undef) : DefaultFactory($rhObject->{'Type'},$rhObject->{'Data'} || [],$rhObject->{'Id'} ? $this->{$Context}->{$rhObject->{'Id'}} : undef);
       
     die new Exception("Trying to close a non existing oject") if not $rhObject;
   
@@ -284,6 +284,15 @@
   scalar keys %{"$_[0]::"} ? 1 : 0;
 }
 
+{
+	my %classes;
+	sub _load_class {
+		my $class = shift;
+		$classes{$class} = 1;
+		eval "require $class";
+	}
+}
+
 sub DefaultSurrogateHelper {
   my ($Type) = @_;
   
@@ -295,7 +304,7 @@
   } elsif ($Type eq 'HASH') {
     return {};
   } elsif ($Type) {
-    eval "require $Type" unless _is_class($Type);
+    _load_class($Type);
     if (UNIVERSAL::can($Type,'surrogate')) {
       return $Type->surrogate();
     } else {
@@ -350,7 +359,7 @@
       return $refSurogate;
     }
   } else {
-    eval "require $Type; 1;" or warn $@ unless _is_class($Type);
+    _load_class($Type);
     if ( $Type->UNIVERSAL::can('restore') ) {
       return $Type->restore($Data,$refSurogate);
     } else {