[Yapcom checkin] rev 16 - lib/YAPC

[prev] [thread] [next] [lurker] [Date index for 2003/11/24]

From: svn
Subject: [Yapcom checkin] rev 16 - lib/YAPC
Date: 15:01 on 24 Nov 2003
Author: gabor
Date: 2003-11-24 15:01:37 +0200 (Mon, 24 Nov 2003)
New Revision: 16

Modified:
   lib/YAPC/Organizer.pm
   lib/YAPC/Talk.pm
Log:
Talk->get_user_id method seemed superflous.

The attached patch refactors this a little by setting up a has_a
relationship between Talk and Person, and then discarding the method.
by Richard Clamp

Modified: lib/YAPC/Organizer.pm
===================================================================
--- lib/YAPC/Organizer.pm	2003-11-24 12:49:42 UTC (rev 15)
+++ lib/YAPC/Organizer.pm	2003-11-24 13:01:37 UTC (rev 16)
@@ -476,8 +476,7 @@
 
        return $t->output;
     } else {
-       my $talker_id = YAPC::Talk->get_user_id(id => $talk->id);
-       my $person = YAPC::Person->retrieve($talker_id);
+       my $person = $talk->user_id;
        my $text = "Subject: " . $talk->title . "\n";
        $text .= "Speaker: ". $person->fname . "  " . $person->lname . "  " . $person->email . "\n";
        $text .= "Language: " . $talk->language . "\n";

Modified: lib/YAPC/Talk.pm
===================================================================
--- lib/YAPC/Talk.pm	2003-11-24 12:49:42 UTC (rev 15)
+++ lib/YAPC/Talk.pm	2003-11-24 13:01:37 UTC (rev 16)
@@ -6,6 +6,7 @@
 use base 'YAPC::DBI';
 use YAPC::Config;
 __PACKAGE__->set_up_table('talks');
+__PACKAGE__->has_a(user_id => 'YAPC::Person');
 
 =head2 propose
 
@@ -45,25 +46,7 @@
     __PACKAGE__->create(\%args);
 }
 
-=head2 get_user_id
 
-Returns the user id of the Person who submitted the talk
-Arguments:  (id => 'the id of the talk')
-
-=cut
-sub get_user_id {
-   my $self = shift;
-   my %args = @_;   # id => ...
-
-   return undef if not $args{id};
-
-   my @talks;
-   @talks= __PACKAGE__->search(%args);
-   return undef if @talks != 1;
-
-   return $talks[0]->user_id;
-} 
-
 =head2 VERSION
 
 $Id:$

Generated at 16:06 on 24 Nov 2003 by mariachi 0.51