[Bps-public-commit] net-lighthouse branch, master, updated. b812b49d4f53c4bd0d23d660dfae38558acfd833

sunnavy at bestpractical.com sunnavy at bestpractical.com
Tue Sep 8 04:36:32 EDT 2009


The branch, master has been updated
       via  b812b49d4f53c4bd0d23d660dfae38558acfd833 (commit)
      from  b0b66c1dc52a3f56f01f4106ab2b5389b639051e (commit)

Summary of changes:
 lib/Net/Lighthouse/Project/TicketBin.pm |   20 ++++++++++++++++++--
 1 files changed, 18 insertions(+), 2 deletions(-)

- Log -----------------------------------------------------------------
commit b812b49d4f53c4bd0d23d660dfae38558acfd833
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Tue Sep 8 16:36:26 2009 +0800

    add ticket_bin->load($name) support

diff --git a/lib/Net/Lighthouse/Project/TicketBin.pm b/lib/Net/Lighthouse/Project/TicketBin.pm
index b00e88f..a7da13f 100644
--- a/lib/Net/Lighthouse/Project/TicketBin.pm
+++ b/lib/Net/Lighthouse/Project/TicketBin.pm
@@ -37,8 +37,24 @@ __PACKAGE__->meta->make_immutable;
 
 sub load {
     my $self = shift;
-    validate_pos( @_, { type => SCALAR, regex => qr/^\d+$/ } );
+    validate_pos( @_, { type => SCALAR, regex => qr/^\d+|\w+$/ } );
     my $id = shift;
+
+    if ( $id !~ /^\d+$/ ) {
+
+        # so we got a name, let's find it
+        my ($bin) = grep { $_->name eq $id } $self->list;
+        if ($bin) {
+            $id = $bin->id;
+        }
+        else {
+            die "can't find ticket bin $id in project "
+              . $self->project_id
+              . ' in account '
+              . $self->account;
+        }
+    }
+
     my $ua = $self->ua;
     my $url =
         $self->base_url
@@ -259,7 +275,7 @@ rw, Maybe Str
 
 =over 4
 
-=item load( $id ), load_from_xml( $hashref | $xml_string )
+=item load( $id | $name ), load_from_xml( $hashref | $xml_string )
 
 load a ticket bin, return the loaded ticket bin object
 

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list