[Jifty-commit] r1009 - Jifty-DBI/trunk/lib/Jifty/DBI
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Fri May 5 16:30:26 EDT 2006
Author: ewilhelm
Date: Fri May 5 16:30:24 2006
New Revision: 1009
Modified:
Jifty-DBI/trunk/lib/Jifty/DBI/Record.pm
Jifty-DBI/trunk/lib/Jifty/DBI/SchemaGenerator.pm
Log:
lib/Jifty/DBI/SchemaGenerator.pm - undo
lib/Jifty/DBI/Record.pm - undo
** sorry, svk hiccup **
** ignore 996 thru 1007 **
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 May 5 16:30:24 2006
@@ -88,113 +88,6 @@
}
-sub AUTOLOAD {
- my $self = $_[0];
-
- $self->_init_columns() unless $self->COLUMNS;
-
- my ( $column_name, $action ) = $self->_parse_autoload_method($AUTOLOAD);
-
- unless ( $action and $column_name ) {
- my ( $package, $filename, $line ) = caller;
- die "$AUTOLOAD Unimplemented in $package. ($filename line $line) \n";
- }
-
- my $column = $self->column($column_name);
-
- unless ($column) {
- my ( $package, $filename, $line ) = caller;
- die "$AUTOLOAD Unimplemented in $package. ($filename line $line) \n";
- }
-
- no strict 'refs'; # We're going to be defining subs
- if ( $action eq 'read' ) {
- return '' unless $column->readable;
-
- if ( UNIVERSAL::isa( $column->refers_to, "Jifty::DBI::Record" ) ) {
- *{$AUTOLOAD} = sub {
- $_[0]->_to_record( $column_name,
- $_[0]->__value($column_name) );
- };
- } elsif (
- UNIVERSAL::isa( $column->refers_to, "Jifty::DBI::Collection" ) )
- {
- *{$AUTOLOAD} = sub { $_[0]->_collection_value($column_name) };
- } else {
- *{$AUTOLOAD} = sub { return ( $_[0]->_value($column_name) ) };
- }
- goto &$AUTOLOAD;
- } elsif ( $action eq 'write' ) {
- return ( 0, 'Immutable column' ) unless $column->writable;
-
- if ( UNIVERSAL::isa( $column->refers_to, "Jifty::DBI::Record" ) ) {
- *{$AUTOLOAD} = sub {
- my $self = shift;
- my $val = shift;
-
- $val = $val->id
- if UNIVERSAL::isa( $val, 'Jifty::DBI::Record' );
- return (
- $self->_set( column => $column_name, value => $val ) );
- };
- } elsif (
- UNIVERSAL::isa( $column->refers_to, "Jifty::DBI::Collection" ) )
- { # XXX elw: collections land here
- *{$AUTOLOAD} = sub {
- # use YAML; die 'column: ', YAML::Dump($column), " ";
- die "cannot write to referenced column";
- };
- } else {
- *{$AUTOLOAD} = sub {
- return (
- $_[0]->_set( column => $column_name, value => $_[1] ) );
- };
- }
- goto &$AUTOLOAD;
- } elsif ( $action eq 'validate' ) {
- *{$AUTOLOAD}
- = sub { return ( $_[0]->_validate( $column_name, $_[1] ) ) };
- goto &$AUTOLOAD;
- }
-
- else {
- my ( $package, $filename, $line ) = caller;
- die "$AUTOLOAD Unimplemented in $package. ($filename line $line) \n";
- }
-
-}
-
-=head2 _parse_autoload_method $AUTOLOAD
-
-Parses autoload methods and attempts to determine if they're
-set, get or validate calls.
-
-Returns a tuple of (COLUMN_NAME, ACTION);
-
-=cut
-
-sub _parse_autoload_method {
- my $self = shift;
- my $method = shift;
-
- my ( $column_name, $action );
-
- if ( $method =~ /^.*::set_(\w+)$/o ) {
- $column_name = $1;
- $action = 'write';
- } elsif ( $method =~ /^.*::validate_(\w+)$/o ) {
- $column_name = $1;
- $action = 'validate';
-
- } elsif ( $method =~ /^.*::(\w+)$/o ) {
- $column_name = $1;
- $action = 'read';
-
- }
- return ( $column_name, $action );
-
-}
-
=head2 _accessible COLUMN ATTRIBUTE
Private method.
Modified: Jifty-DBI/trunk/lib/Jifty/DBI/SchemaGenerator.pm
==============================================================================
--- Jifty-DBI/trunk/lib/Jifty/DBI/SchemaGenerator.pm (original)
+++ Jifty-DBI/trunk/lib/Jifty/DBI/SchemaGenerator.pm Fri May 5 16:30:24 2006
@@ -208,7 +208,6 @@
Returns a string containing a sequence of SQL statements to create tables for all of
the models added to the SchemaGenerator.
-=end
=cut
More information about the Jifty-commit
mailing list