[Rt-commit] [svn] r787 - in RT-Client: . lib/RT

autrijus at pallas.eruditorum.org autrijus at pallas.eruditorum.org
Sat May 1 07:43:25 EDT 2004


Author: autrijus
Date: Sat May  1 07:43:25 2004
New Revision: 787

Modified:
   RT-Client/   (props changed)
   RT-Client/lib/RT/Client.pm
Log:
 ----------------------------------------------------------------------
 r4329 at not:  autrijus | 2004-05-01T11:43:26.221614Z
 
 * new() now takes initialization parameters.
 ----------------------------------------------------------------------


Modified: RT-Client/lib/RT/Client.pm
==============================================================================
--- RT-Client/lib/RT/Client.pm	(original)
+++ RT-Client/lib/RT/Client.pm	Sat May  1 07:43:25 2004
@@ -23,10 +23,11 @@
 
     use RT::Client;
 
-    my $rt = RT::Client->new;
-    $rt->username('root');
-    $rt->password('password');
-    $rt->server('http://localhost');
+    my $rt = RT::Client->new(
+        Username    => 'root',
+        Password    => 'password',
+        Server      => 'http://localhost',
+    );
 
     # search / list
     my $tickets = $rt->search(
@@ -82,16 +83,27 @@
         no strict 'refs';
         *$key1 = *$key2 = sub {
             my $self = shift;
-            my $uri    = shift;
+            my %args = (@_ > 1) ? @_ : (URI => $_[0]);
             return $self->can($method)->(
                 $self,
-                $self->server_uri($uri),
-                @_,
+                $self->server_uri($args{URI}),
+                %args,
             );
         };
     }
 }
 
+sub new {
+    my ($class, %args) = @_;
+    my $self = $class->SUPER::new(%args);
+
+    $self->username($args{Username}) if defined $args{Username};
+    $self->password($args{Password}) if defined $args{Password};
+    $self->server($args{Server})     if defined $args{Server};
+
+    return $self;
+}
+
 sub password {
     my $self = shift;
 


More information about the Rt-commit mailing list