[Jifty-commit] r2858 - in Jifty-DBI/branches/od: . lib/Jifty/DBI

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Tue Feb 27 21:58:05 EST 2007


Author: jesse
Date: Tue Feb 27 21:58:04 2007
New Revision: 2858

Added:
   Jifty-DBI/branches/od/lib/Jifty/DBI/Record/Plugin.pm
Modified:
   Jifty-DBI/branches/od/   (props changed)
   Jifty-DBI/branches/od/lib/Jifty/DBI/Record.pm
   Jifty-DBI/branches/od/lib/Jifty/DBI/Schema.pm

Log:
 r48582 at pinglin:  jesse | 2007-02-27 21:57:40 -0500
 * Initial stab at a mixin-based Jifty::DBI::Record plugin system.


Modified: Jifty-DBI/branches/od/lib/Jifty/DBI/Record.pm
==============================================================================
--- Jifty-DBI/branches/od/lib/Jifty/DBI/Record.pm	(original)
+++ Jifty-DBI/branches/od/lib/Jifty/DBI/Record.pm	Tue Feb 27 21:58:04 2007
@@ -384,7 +384,7 @@
 sub column {
     my $self = shift;
     my $name = lc( shift || '' );
-    my $col = $self->COLUMNS;
+    my $col = $self->_columns_hashref;
     return undef unless $col && exists $col->{$name};
     return $col->{$name};
 
@@ -406,13 +406,20 @@
                 <=> ( ( $a->type || '' ) eq 'serial' ) )
                 or ( ($a->sort_order || 0) <=> ($b->sort_order || 0))
                 or ( $a->name cmp $b->name )
-            } values %{ $self->COLUMNS || {} }
+            } values %{ $self->_columns_hashref }
 
 
 	])}
 
 }
 
+sub _columns_hashref {
+    my $self = shift;
+
+      return ($self->COLUMNS||{});
+}
+
+
 # sub {{{ readable_attributes
 
 =head2 readable_attributes

Added: Jifty-DBI/branches/od/lib/Jifty/DBI/Record/Plugin.pm
==============================================================================
--- (empty file)
+++ Jifty-DBI/branches/od/lib/Jifty/DBI/Record/Plugin.pm	Tue Feb 27 21:58:04 2007
@@ -0,0 +1,17 @@
+package Jifty::DBI::Record::Plugin;
+
+use warnings;
+use strict;
+use Carp;
+
+sub import {
+    my $self = shift;
+    my $caller = caller;
+    for ($self->columns) {
+            $caller->COLUMNS->{$_->name} = $_ ;
+            $self->_init_methods_for_column($_);
+    }
+ return 1;
+}
+
+1;

Modified: Jifty-DBI/branches/od/lib/Jifty/DBI/Schema.pm
==============================================================================
--- Jifty-DBI/branches/od/lib/Jifty/DBI/Schema.pm	(original)
+++ Jifty-DBI/branches/od/lib/Jifty/DBI/Schema.pm	Tue Feb 27 21:58:04 2007
@@ -205,8 +205,8 @@
 	}
 
 	# Then initialize all columns
-	foreach my $column ( sort keys %{ $from->COLUMNS || {} } ) {
-	    $from->_init_methods_for_column( $from->COLUMNS->{$column} );
+	foreach my $column ( sort keys %{ $from->_columns_hashref } ) {
+	    $from->_init_methods_for_column( $from->_columns_hashref->{$column} );
 	}
     };
 


More information about the Jifty-commit mailing list