[Jifty-commit] r1567 - Jifty-DBI/trunk/lib/Jifty/DBI
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Thu Jul 13 22:30:18 EDT 2006
Author: audreyt
Date: Thu Jul 13 22:30:16 2006
New Revision: 1567
Modified:
Jifty-DBI/trunk/lib/Jifty/DBI/Record.pm
Jifty-DBI/trunk/lib/Jifty/DBI/Schema.pm
Log:
* Remove the @ISA-mocking code from Jifty::DBI::Schema, so that
use MyApp::Record schema {
...;
}
can work even if MyApp::Record overrides Jifty::Record's column
building methods. We do that by arranging the schema callback
to run after the @ISA chain is set up.
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 Thu Jul 13 22:30:16 2006
@@ -87,6 +87,10 @@
no strict 'refs';
push @{$descendant . '::ISA'}, $class;
shift;
+
+ # run the schema callback
+ my $callback = shift;
+ $callback->() if $callback;
}
$class->SUPER::import(@_);
}
Modified: Jifty-DBI/trunk/lib/Jifty/DBI/Schema.pm
==============================================================================
--- Jifty-DBI/trunk/lib/Jifty/DBI/Schema.pm (original)
+++ Jifty-DBI/trunk/lib/Jifty/DBI/Schema.pm Thu Jul 13 22:30:16 2006
@@ -71,25 +71,17 @@
my $from = (caller)[0];
- if ( UNIVERSAL::isa($from, 'Jifty::DBI::Record') ) {
- # We run the code as usual if the caller is J::D::R.
+ my $new_code = sub {
$code->();
- }
- else {
- # If the caller is not, we temporarily make it so.
- require Jifty::DBI::Record;
- no strict 'refs';
- local @{"$from\::ISA"} = (@{"$from\::ISA"}, 'Jifty::DBI::Record');
- $code->();
- }
-
- # Unimport all our symbols from the calling package.
- foreach my $sym (@EXPORT) {
- no strict 'refs';
- undef *{"$from\::$sym"};
- }
- return '-base';
+ # Unimport all our symbols from the calling package.
+ foreach my $sym (@EXPORT) {
+ no strict 'refs';
+ undef *{"$from\::$sym"};
+ }
+ };
+
+ return('-base' => $new_code);
}
=head2 column
More information about the Jifty-commit
mailing list