[Opensrf-commits] r1787 - trunk/src/perl/lib/OpenSRF/Utils (sboyette)

svn at svn.open-ils.org svn at svn.open-ils.org
Tue Sep 15 12:19:49 EDT 2009


Author: sboyette
Date: 2009-09-15 12:19:45 -0400 (Tue, 15 Sep 2009)
New Revision: 1787

Modified:
   trunk/src/perl/lib/OpenSRF/Utils/JSON.pm
Log:
more test

Modified: trunk/src/perl/lib/OpenSRF/Utils/JSON.pm
===================================================================
--- trunk/src/perl/lib/OpenSRF/Utils/JSON.pm	2009-09-15 16:19:45 UTC (rev 1786)
+++ trunk/src/perl/lib/OpenSRF/Utils/JSON.pm	2009-09-15 16:19:45 UTC (rev 1787)
@@ -50,11 +50,13 @@
 =cut
 
 sub register_class_hint {
-    # FIXME hint can't be a dupe
-    # FIXME fail unless we have hint and name
+    # FIXME hint can't be a dupe?
+    # FIXME fail unless we have hint and name?
+    # FIXME validate hint against IDL?
     my ($pkg, %args) = @_;
-    # FIXME why is the same thing shoved into two places? One mapping
-    # would suffice if class and hint were always returned together...
+    # FIXME maybe not just store a reference to %args; the lookup
+    # functions are really confusing at first glance as a side effect
+    # of this
     $_class_map{hints}{$args{hint}} = \%args;
     $_class_map{classes}{$args{name}} = \%args;
 }
@@ -101,12 +103,25 @@
 
 sub rawJSON2perl {
     my ($pkg, $json) = @_;
-    # FIXME change regex conditional to '=~ /\S/'
-    return undef unless (defined $json and $json !~ /^\s*$/o);
+    return undef unless (defined $json and $json =~ /\S/o);
     return $parser->decode($json);
 }
 
 
+=head2 rawPerl2JSON
+
+Intermediate routine used by L</Perl2JSON>.
+
+=cut
+
+sub rawPerl2JSON {
+    # FIXME is there a reason this doesn't return undef with no
+    # content as rawJSON2perl does?
+    my ($pkg, $perl) = @_;
+    return $parser->encode($perl);
+}
+
+
 =head2 JSONObject2Perl
 
 Final routine in the object re-vivification chain, called by L</rawJSON2perl>.
@@ -152,19 +167,6 @@
 }
 
 
-=head2 rawPerl2JSON
-
-Intermediate routine used by L</Perl2JSON>.
-
-=cut
-
-sub rawPerl2JSON {
-    # FIXME no validation of any sort
-    my ($pkg, $perl) = @_;
-    return $parser->encode($perl);
-}
-
-
 =head2 perl2JSONObject
 
 =cut
@@ -205,6 +207,7 @@
     # they're named after. best case: flatten _class_map, since hints
     # and classes are identical
     my ($pkg, $hint) = @_;
+    return undef unless $hint;
     return $_class_map{hints}{$hint}{name}
 }
 
@@ -215,6 +218,7 @@
 
 sub lookup_hint {
     my ($pkg, $class) = @_;
+    return undef unless $class;
     return $_class_map{classes}{$class}{hint}
 }
 



More information about the opensrf-commits mailing list