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.
-# $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;
host => $host,
port => $port,
_conn => $_conn,
- };
+ }, $class;
$conn->_check();
return $conn;
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 {