Move Fieldmapper API call to Application.pm
authorBill Erickson <berick@esilibrary.com>
Wed, 8 Aug 2012 18:26:31 +0000 (14:26 -0400)
committerBill Erickson <berick@esilibrary.com>
Wed, 8 Aug 2012 18:26:31 +0000 (14:26 -0400)
Move export of opensrf.open-ils.system.fieldmapper API call from
Fieldmapper.pm into Application.pm with the rest of the shared API
calls.  This allows us to remove the OpenSRF::Application base from
Fieldmapper, which was causing some method name collisions.  For
example, if a Fieldmapper object had a field called "session", which,
incidentally, is also a method of OpenSRF::Application, the version
from OpenSRF::Application would get called instead of the Fieldmapper
version, since Fieldmapper methods are defined during AUTOLOAD.
Hilarity was guaranteed to ensue.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/perlmods/lib/OpenILS/Application.pm
Open-ILS/src/perlmods/lib/OpenILS/Utils/Fieldmapper.pm

index cd4dbbf..2888c93 100644 (file)
@@ -2,6 +2,7 @@ package OpenILS::Application;
 use OpenSRF::Application;
 use UNIVERSAL::require;
 use base qw/OpenSRF::Application/;
+use OpenILS::Utils::Fieldmapper;
 
 sub ils_version {
     # version format is "x-y-z", for example "2-0-0" for Evergreen 2.0.0
@@ -25,6 +26,19 @@ sub get_idl_file {
     return OpenSRF::Utils::SettingsClient->new->config_value('IDL');
 }
 
+sub publish_fieldmapper {
+       my ($self,$client,$class) = @_;
+
+       return $Fieldmapper::fieldmap unless (defined $class);
+       return undef unless (exists($$Fieldmapper::fieldmap{$class}));
+       return {$class => $$Fieldmapper::fieldmap{$class}};
+}
+__PACKAGE__->register_method(
+       api_name        => 'opensrf.open-ils.system.fieldmapper',
+       api_level       => 1,
+       method          => 'publish_fieldmapper',
+);
+
 sub register_method {
     my $class = shift;
     my %args = @_;
index 33050fd..709ad5c 100644 (file)
@@ -1,7 +1,6 @@
 package Fieldmapper;
 use OpenSRF::Utils::JSON;
 use Data::Dumper;
-use base 'OpenSRF::Application';
 use OpenSRF::Utils::Logger;
 use OpenSRF::Utils::SettingsClient;
 use OpenSRF::System;
@@ -12,19 +11,6 @@ my $log = 'OpenSRF::Utils::Logger';
 
 use vars qw/$fieldmap $VERSION/;
 
-sub publish_fieldmapper {
-       my ($self,$client,$class) = @_;
-
-       return $fieldmap unless (defined $class);
-       return undef unless (exists($$fieldmap{$class}));
-       return {$class => $$fieldmap{$class}};
-}
-__PACKAGE__->register_method(
-       api_name        => 'opensrf.open-ils.system.fieldmapper',
-       api_level       => 1,
-       method          => 'publish_fieldmapper',
-);
-
 #
 # To dump the Javascript version of the fieldmapper struct use the command:
 #