LP#1347774 CStoreEditor pcrud needs object 'type' and 'hint' info at rumtime
authorBill Erickson <berick@esilibrary.com>
Fri, 1 Aug 2014 19:24:30 +0000 (15:24 -0400)
committerBill Erickson <berick@esilibrary.com>
Fri, 1 Aug 2014 19:27:11 +0000 (15:27 -0400)
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/perlmods/lib/OpenILS/Utils/CStoreEditor.pm

index 87f11d0..e04c686 100644 (file)
@@ -743,7 +743,7 @@ sub __arg_to_string {
 # return $e->event unless @$results; 
 # -----------------------------------------------------------------------------
 sub runmethod {
-    my( $self, $action, $type, $arg, $options ) = @_;
+    my( $self, $action, $type, $hint, $arg, $options ) = @_;
 
    $options ||= {};
 
@@ -762,7 +762,7 @@ sub runmethod {
     my @arg = ( ref($arg) eq 'ARRAY' ) ? @$arg : ($arg);
     my $method = '';
     if ($self->personality eq 'open-ils.pcrud') {
-        $method = $self->app.".$action.$type";
+        $method = $self->app.".$action.$hint";
     } else {
         $method = $self->app.".direct.$type.$action";
     }
@@ -919,14 +919,10 @@ sub init {
     my $map = $Fieldmapper::fieldmap;
     for my $object (keys %$map) {
         my $obj  = __fm2meth($object, '_');
-        my $type;
-        if (__PACKAGE__->personality eq 'open-ils.pcrud') {
-            $type = $object->json_hint;
-        } else {
-            $type = __fm2meth($object, '.');
-        }
+        my $type = __fm2meth($object, '.');
+        my $hint = $object->json_hint;
         foreach my $command (qw/ update retrieve search create delete batch_retrieve retrieve_all /) {
-            eval "sub ${command}_$obj {return shift()->runmethod('$command', '$type', \@_);}\n";
+            eval "sub ${command}_$obj {return shift()->runmethod('$command', '$type', '$hint', \@_);}\n";
         }
         # TODO: performance test against concatenating a big string of all the subs and eval'ing only ONCE.
     }