From a95c770afda7f938e9ca31c070b10d64686253da Mon Sep 17 00:00:00 2001 From: mike Date: Tue, 10 Oct 2006 17:02:27 +0000 Subject: [PATCH] Connection::new() refactored to use create() This means it can take an options-object argument. --- lib/ZOOM.pm | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/lib/ZOOM.pm b/lib/ZOOM.pm index 48af46a..2fa8be2 100644 --- a/lib/ZOOM.pm +++ b/lib/ZOOM.pm @@ -1,4 +1,4 @@ -# $Id: ZOOM.pm,v 1.37 2006-10-10 16:51:59 mike Exp $ +# $Id: ZOOM.pm,v 1.38 2006-10-10 17:02:27 mike Exp $ use strict; use warnings; @@ -314,25 +314,13 @@ sub new { my $class = shift(); my($host, $port, @options) = @_; - my $_opts = Net::Z3950::ZOOM::options_create(); - while (@options >= 2) { - my $key = shift(@options); - my $val = shift(@options); - Net::Z3950::ZOOM::options_set($_opts, $key, $val); - } - - die "Odd number of options specified" - if @options; - - my $_conn = Net::Z3950::ZOOM::connection_create($_opts); - Net::Z3950::ZOOM::connection_connect($_conn, $host, $port || 0); - my $conn = bless { - host => $host, - port => $port, - _conn => $_conn, - }, $class; + my $conn = $class->create(@options); + $conn->{host} = $host; + $conn->{port} = $port; + Net::Z3950::ZOOM::connection_connect($conn->_conn(), $host, $port || 0); $conn->_check(); + return $conn; } @@ -377,11 +365,12 @@ sub create { } my $_conn = Net::Z3950::ZOOM::connection_create($_opts); - return bless { + my $conn = bless { host => undef, port => undef, _conn => $_conn, }, $class; + return $conn; } sub error_x { -- 1.7.10.4