morphing into shape
authorerickson <erickson@9efc2488-bf62-4759-914b-345cdb29e865>
Thu, 31 Mar 2005 19:11:40 +0000 (19:11 +0000)
committererickson <erickson@9efc2488-bf62-4759-914b-345cdb29e865>
Thu, 31 Mar 2005 19:11:40 +0000 (19:11 +0000)
git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@258 9efc2488-bf62-4759-914b-345cdb29e865

src/extras/fieldmapper.pl

index bd90d0b..defcd73 100644 (file)
@@ -10,8 +10,17 @@ print <<JS;
 
 //  ----------------------------------------------------------------
 // Autogenerated by fieldmapper.pl
+// Requires JSON.js
 //  ----------------------------------------------------------------
 
+function FieldmapperException(message) {
+       this.message = message;
+}
+FieldmapperException.toString = function() {
+       return "FieldmapperException: " + this.message + "\\n";
+}
+
+
 JS
 
 for my $object (keys %$map) {
@@ -27,12 +36,26 @@ print <<JS;
 JS
 
 print  <<JS;
+
 function $short_name(array) {
-       if(array) { this.array = array; } 
-       else { this.array = []; }
+
+       this.classname = "$short_name";
+       this._isfieldmapper = true;
+
+       if(array) { 
+               if( array.constructor == Array) 
+                       this.array = array;  
+
+               else
+                       throw new FieldmapperException(
+                               "Attempt to build fieldmapper object with non-array");
+
+       } else { this.array = []; }
+
 }
 
-$short_name.classname = "$short_name";
+$short_name._isfieldmapper = true;
+
 
 JS