[Jifty-commit] r2934 - in jifty/trunk: lib/Jifty
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Fri Mar 9 16:24:09 EST 2007
Author: jesse
Date: Fri Mar 9 16:23:57 2007
New Revision: 2934
Modified:
jifty/trunk/ (props changed)
jifty/trunk/lib/Jifty/ClassLoader.pm
Log:
r53241 at pinglin: jesse | 2007-03-09 16:17:49 -0500
* ClassLoader refactoring in advance of plugin fixing.
Modified: jifty/trunk/lib/Jifty/ClassLoader.pm
==============================================================================
--- jifty/trunk/lib/Jifty/ClassLoader.pm (original)
+++ jifty/trunk/lib/Jifty/ClassLoader.pm Fri Mar 9 16:23:57 2007
@@ -117,39 +117,36 @@
$module =~ s{/}{::}g;
# The quick check
- return undef unless $module =~ m!^$base!;
+ return undef unless $module =~ /^$base/;
if ( $module =~ m!^(?:$base)$! ) {
return $self->return_class(
- "use warnings; use strict; package " . $base . ";\n" . " 1;" );
+ "package " . $base . ";\n");
}
-# elsif ( $module =~ m!^(?:$base)::Action$! ) {
-# return $self->return_class(
-# "use warnings; use strict; package $module;\n"
-# . "use base qw/Jifty::Action/; sub _autogenerated { 1 };\n"
-# . "1;" );
-# }
- elsif ( $module =~ m!^(?:$base)::(Record|Collection|Notification|Dispatcher|Bootstrap|Upgrade|Handle|Event|Event::Model|Action::Record::\w+)$! ) {
+ elsif ( $module =~ m/^(?:$base)::(Record|Collection|Notification|
+ Dispatcher|Bootstrap|Upgrade|
+ Handle|Event|Event::Model|
+ Action::Record::\w+)$/x ) {
return $self->return_class(
- "use warnings; use strict; package $module;\n"
+ "package $module;\n"
. "use base qw/Jifty::$1/; sub _autogenerated { 1 };\n"
- . "1;" );
+ );
} elsif ( $module =~ m!^(?:$base)::View$! ) {
return $self->return_class(
- "use warnings; use strict; package $module;\n"
+ "package $module;\n"
. "use base qw/Jifty::View::Declare::Helpers/; sub _autogenerated { 1 };\n"
- . "1;" );
+ );
} elsif ( $module =~ m!^(?:$base)::CurrentUser$! ) {
return $self->return_class(
- "use warnings; use strict; package $module;\n"
+ "package $module;\n"
. "use base qw/Jifty::CurrentUser/; sub _autogenerated { 1 };\n"
- . "1;" );
+ );
} elsif ( $module =~ m!^(?:$base)::Model::(\w+)Collection$! ) {
return $self->return_class(
- "use warnings; use strict; package $module;\n"
+ "package $module;\n"
. "use base qw/@{[$base]}::Collection/;\n"
. "sub record_class { '@{[$base]}::Model::$1' }\n"
- . "1;" );
+ );
} elsif ( $module =~ m!^(?:$base)::Event::Model::([^\.]+)$! ) {
my $modelclass = $base . "::Model::" . $1;
Jifty::Util->require($modelclass);
@@ -157,11 +154,11 @@
return undef unless eval { $modelclass->table };
return $self->return_class(
- "use warnings; use strict; package $module;\n"
+ "package $module;\n"
. "use base qw/${base}::Event::Model/;\n"
. "sub record_class { '$modelclass' };\n"
. "sub autogenerated { 1 };\n"
- . "1;" );
+ );
} elsif ( $module =~ m!^(?:$base)::Action::(Create|Update|Delete|Search)([^\.]+)$! ) {
my $modelclass = $base . "::Model::" . $2;
@@ -170,11 +167,11 @@
return undef unless eval { $modelclass->table };
return $self->return_class(
- "use warnings; use strict; package $module;\n"
+ "package $module;\n"
. "use base qw/$base\::Action::Record::$1/;\n"
. "sub record_class { '$modelclass' };\n"
. "sub autogenerated { 1 };\n"
- . "1;" );
+ );
}
return undef;
}
@@ -190,6 +187,7 @@
my $self = shift;
my $content = shift;
+ $content = "use warnings; use strict; ". $content . "\n1;";
open my $fh, '<', \$content;
return $fh;
More information about the Jifty-commit
mailing list