From: mike Date: Tue, 10 Oct 2006 16:51:59 +0000 (+0000) Subject: - Fix bug in ZOOM::Connection class code that made the X-Git-Tag: cpan_1_22~119 X-Git-Url: http://jsfdemo.indexdata.com/cgi-bin?a=commitdiff_plain;h=c1ff60d1378d49166ea3bd6a2da0c7b7550e940e;p=ZOOM-Perl-moved-to-github.git - Fix bug in ZOOM::Connection class code that made the difficult to subclass -- when called as $class->SUPER::new(@_), the constructor blessed the new object into ZOOM::Connection rather than info the subclass. - ZOOM::Connection::create() may now take either a single argument, which is a ZOOM::Options object, or any even number of argument (including zero), which are key => value pairs of options to set. --- diff --git a/lib/ZOOM.pm b/lib/ZOOM.pm index 0e3e583..48af46a 100644 --- a/lib/ZOOM.pm +++ b/lib/ZOOM.pm @@ -1,4 +1,4 @@ -# $Id: ZOOM.pm,v 1.36 2006-10-04 17:15:03 mike Exp $ +# $Id: ZOOM.pm,v 1.37 2006-10-10 16:51:59 mike Exp $ use strict; use warnings; @@ -330,7 +330,7 @@ sub new { host => $host, port => $port, _conn => $_conn, - }; + }, $class; $conn->_check(); return $conn; @@ -359,14 +359,29 @@ sub _check { sub create { my $class = shift(); - my($options) = @_; + my(@options) = @_; + + my $_opts; + if (@_ == 1) { + $_opts = $_[0]->_opts(); + } else { + $_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); + } - my $_conn = Net::Z3950::ZOOM::connection_create($options->_opts()); + die "Odd number of options specified" + if @options; + } + + my $_conn = Net::Z3950::ZOOM::connection_create($_opts); return bless { host => undef, port => undef, _conn => $_conn, - }; + }, $class; } sub error_x {