From: mike Date: Tue, 10 Oct 2006 17:02:27 +0000 (+0000) Subject: Connection::new() refactored to use create() X-Git-Tag: cpan_1_22~116 X-Git-Url: http://git.indexdata.com/?a=commitdiff_plain;ds=sidebyside;h=a95c770afda7f938e9ca31c070b10d64686253da;p=ZOOM-Perl-moved-to-github.git Connection::new() refactored to use create() This means it can take an options-object argument. --- 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 {