[Rt-commit] r3858 - in Jifty-DBI/trunk: . lib/Jifty/DBI t

jesse at bestpractical.com jesse at bestpractical.com
Fri Sep 16 23:24:30 EDT 2005


Author: jesse
Date: Fri Sep 16 23:24:29 2005
New Revision: 3858

Modified:
   Jifty-DBI/trunk/   (props changed)
   Jifty-DBI/trunk/Makefile.PL
   Jifty-DBI/trunk/lib/Jifty/DBI/Record.pm
   Jifty-DBI/trunk/t/01records.t
   Jifty-DBI/trunk/t/11schema_records.t
   Jifty-DBI/trunk/t/testmodels.pl
Log:
 r15782 at hualien:  jesse | 2005-09-16 23:23:55 -0400
  * A bit more cleanup to Record.pm, thanks to ruslan


Modified: Jifty-DBI/trunk/Makefile.PL
==============================================================================
--- Jifty-DBI/trunk/Makefile.PL	(original)
+++ Jifty-DBI/trunk/Makefile.PL	Fri Sep 16 23:24:29 2005
@@ -7,6 +7,7 @@
 requires('Want');
 requires('Encode');
 requires('UNIVERSAL::require');
+requires('Lingua::EN::Inflect');
 requires('Class::ReturnValue', 0.40);
 requires('Cache::Simple::TimedExpiry' => '0.21');
 build_requires('Test::More' => 0.52);

Modified: Jifty-DBI/trunk/lib/Jifty/DBI/Record.pm
==============================================================================
--- Jifty-DBI/trunk/lib/Jifty/DBI/Record.pm	(original)
+++ Jifty-DBI/trunk/lib/Jifty/DBI/Record.pm	Fri Sep 16 23:24:29 2005
@@ -913,12 +913,6 @@
 
 }
 
-# load should do a bit of overloading
-# if we call it with only one argument, we're trying to load by reference.
-# if we call it with a passel of arguments, we're trying to load by value
-# The latter is primarily important when we've got a whole set of record that we're
-# reading in with a recordset class and want to instantiate objefcts for each record.
-
 =head2 load
 
 Takes a single argument, $id. Calls load_by_cols to retrieve the row whose primary key
@@ -929,24 +923,9 @@
 sub load {
     my $self = shift;
 
-    return $self->load_by_cols(id=>@_);
+    return $self->load_by_cols(id=>shift);
 }
 
-=head2 load_by_col
-
-Takes two arguments, a column and a value. The column can be any table column
-which contains unique values.  Behavior when using a non-unique value is
-undefined
-
-=cut
-
-sub load_by_col {
-    my $self = shift;
-    my $col  = shift;
-    my $val  = shift;
-
-    return ( $self->load_by_cols( $col => $val ) );
-}
 
 =head2 load_by_cols
 
@@ -1180,11 +1159,10 @@
 
 sub table {
     my $self = shift;
-    use Carp; die Carp::longmess unless ref $self;
 
     if (not $self->{__table_name} ) {
 	    my $class = ref($self);
-	    die "Couldn't turn ".$class." into a table name" unless ($class =~ /::(\w+)$/);
+	    die "Couldn't turn ".$class." into a table name" unless ($class =~ /(?:\:\:)?(\w+)$/);
             my $table = $1;
             $table =~ s/(?<=[a-z])([A-Z]+)/"_" . lc($1)/eg;
             $table =~ tr/A-Z/a-z/;

Modified: Jifty-DBI/trunk/t/01records.t
==============================================================================
--- Jifty-DBI/trunk/t/01records.t	(original)
+++ Jifty-DBI/trunk/t/01records.t	Fri Sep 16 23:24:29 2005
@@ -140,12 +140,12 @@
 	is( $newrec->id, undef, "can't load record with undef id");
 
 	$newrec = TestApp::Address->new($handle);
-	$newrec->load_by_col( name => '12345678901234' );
+	$newrec->load_by_cols( name => '12345678901234' );
 	is( $newrec->id, $newid, "load record by 'name' column value");
 
 # load_by_col with operator
 	$newrec = TestApp::Address->new($handle);
-	$newrec->load_by_col( name => { value => '%45678%',
+	$newrec->load_by_cols( name => { value => '%45678%',
 				      operator => 'LIKE' } );
 	is( $newrec->id, $newid, "load record by 'name' with LIKE");
 

Modified: Jifty-DBI/trunk/t/11schema_records.t
==============================================================================
--- Jifty-DBI/trunk/t/11schema_records.t	(original)
+++ Jifty-DBI/trunk/t/11schema_records.t	Fri Sep 16 23:24:29 2005
@@ -240,7 +240,6 @@
 
 use base qw/Jifty::DBI::Record/;
 
-sub table { 'employees' }
 
 sub schema {
     return {
@@ -262,7 +261,6 @@
 
 use base qw/Jifty::DBI::Record/;
 
-sub table { 'phones' }
 
 sub schema {
     return {   

Modified: Jifty-DBI/trunk/t/testmodels.pl
==============================================================================
--- Jifty-DBI/trunk/t/testmodels.pl	(original)
+++ Jifty-DBI/trunk/t/testmodels.pl	Fri Sep 16 23:24:29 2005
@@ -4,7 +4,6 @@
 
 # Class and instance method
 
-sub table { "addresses" }
 
 # Class and instance method
 
@@ -20,7 +19,6 @@
 
 use base qw/Jifty::DBI::Record/;
 
-sub table { "employees" }
 
 sub schema {
     return {


More information about the Rt-commit mailing list