From c89cba2a8722dc3a8186fea15b24ef0ec371492a Mon Sep 17 00:00:00 2001 From: Chris Cormack Date: Mon, 18 Nov 2013 15:14:55 +1300 Subject: [PATCH] Shifting the ILS call to NCIP.pm from Configuration.pm --- lib/NCIP.pm | 9 ++++++++- lib/NCIP/Configuration.pm | 5 ----- lib/NCIP/ILS/Koha.pm | 6 ++++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/lib/NCIP.pm b/lib/NCIP.pm index 75f9e68..b962b1e 100644 --- a/lib/NCIP.pm +++ b/lib/NCIP.pm @@ -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; } diff --git a/lib/NCIP/Configuration.pm b/lib/NCIP/Configuration.pm index a1d816a..a5d4c6c 100644 --- a/lib/NCIP/Configuration.pm +++ b/lib/NCIP/Configuration.pm @@ -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; } diff --git a/lib/NCIP/ILS/Koha.pm b/lib/NCIP/ILS/Koha.pm index 725f84a..51156b1 100644 --- a/lib/NCIP/ILS/Koha.pm +++ b/lib/NCIP/ILS/Koha.pm @@ -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; -- 2.43.2