Shifting the ILS call to NCIP.pm from Configuration.pm
authorChris Cormack <chrisc@catalyst.net.nz>
Mon, 18 Nov 2013 02:14:55 +0000 (15:14 +1300)
committerChris Cormack <chrisc@catalyst.net.nz>
Mon, 18 Nov 2013 02:14:55 +0000 (15:14 +1300)
lib/NCIP.pm
lib/NCIP/Configuration.pm
lib/NCIP/ILS/Koha.pm

index 75f9e68..b962b1e 100644 (file)
@@ -4,8 +4,9 @@ use NCIP::Handler;
 use Modern::Perl;
 use XML::LibXML;
 use Try::Tiny;
+use Module::Load;
 
-use Object::Tiny qw{xmldoc config namespace};
+use Object::Tiny qw{xmldoc config namespace ils};
 
 our $VERSION = '0.01';
 our $nsURI   = 'http://www.niso.org/2008/ncip';
@@ -31,6 +32,12 @@ sub new {
     my $config     = NCIP::Configuration->new($config_dir);
     $self->{config}    = $config;
     $self->{namespace} = $nsURI;
+
+    # load the ILS dependent module
+    my $module = 'NCIP::ILS::' . $config->('NCIP.ils.value');
+    load $module || die "Can not load ILS module $module";
+    my $ils = $module->new(  name => $config->('NCIP.ils.value')  );
+    $self->{'ils'} = $ils;
     return bless $self, $class;
 
 }
index a1d816a..a5d4c6c 100644 (file)
@@ -30,7 +30,6 @@ package NCIP::Configuration;
 =cut
 
 use Modern::Perl;
-use Module::Load;
 use NCIP::Configuration::Service;
 use base qw(Config::Merge);
 
@@ -52,10 +51,6 @@ sub new {
         $listeners{ lc $service->{'port'} } = $serv_object;
     }
     $self->{'listeners'} = \%listeners;
-    my $module = 'NCIP::ILS::'.$self->('NCIP.ils.value');
-    load $module;
-    my $ils = $module->new();
-    $self->{'ils'}=$ils;
     return $self;
 }
 
index 725f84a..51156b1 100644 (file)
@@ -3,7 +3,7 @@
 #
 #         FILE: Koha.pm
 #
-#  DESCRIPTION: 
+#  DESCRIPTION:
 #
 #        FILES: ---
 #         BUGS: ---
@@ -14,7 +14,9 @@
 #      CREATED: 05/11/13 11:14:09
 #     REVISION: ---
 #===============================================================================
+package NCIP::ILS::Koha;
 
 use Modern::Perl;
+use Object::Tiny qw{ name };
+
 1;