LP1825851 CStoreEditor instance specific personality
authorBill Erickson <berickxx@gmail.com>
Thu, 11 Jul 2019 21:20:45 +0000 (17:20 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Thu, 8 Aug 2019 19:41:08 +0000 (15:41 -0400)
Allow applying a CStoreEditor personality to individual editor instances
without overwriting the default / process-wide personality.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Kyle Huckins <khuckins@catalyte.io>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/perlmods/lib/OpenILS/Utils/CStoreEditor.pm

index e381b21..dab85c0 100644 (file)
@@ -52,9 +52,25 @@ our $personality = 'open-ils.cstore';
 
 sub personality { 
     my( $self, $app ) = @_;
-    $personality = $app if $app;
-    init() if $app; # rewrite if we changed personalities
-    return $personality;
+
+    if (ref($self)) {
+        # Instance-specific personality
+
+        if ($app) {
+            $self->{personality} = $app;
+            init();
+        }
+        return $self->{personality} || $personality;
+
+    } else {
+        # Process default personality
+
+        if ($app) {
+            $personality = $app;
+            init();
+        }
+        return $personality;
+    }
 }
 
 sub import {