Permalink
Browse files

Revert "Added Plack::Util::convert_to_app($app) using more generic co…

…deref overloading"

This reverts commit 0759abe.
  • Loading branch information...
1 parent 0759abe commit 4a7e5a4dd0569ef875088ef67dbb6a034e9425c3 @miyagawa miyagawa committed Feb 8, 2013
Showing with 14 additions and 16 deletions.
  1. +1 −1 lib/Plack/Builder.pm
  2. +12 −1 lib/Plack/Component.pm
  3. +1 −1 lib/Plack/Runner.pm
  4. +0 −13 lib/Plack/Util.pm
View
@@ -124,7 +124,7 @@ sub builder(&) {
}
}
- $app = Plack::Util::convert_to_app($app);
+ $app = $app->to_app if $app and Scalar::Util::blessed($app) and $app->can('to_app');
$self->to_app($app);
}
View
@@ -3,7 +3,7 @@ use strict;
use warnings;
use Carp ();
use Plack::Util;
-use overload '&{}' => \&to_app, fallback => 1;
+use overload '&{}' => \&to_app_auto, fallback => 1;
sub new {
my $proto = shift;
@@ -19,6 +19,17 @@ sub new {
$self;
}
+sub to_app_auto {
+ my $self = shift;
+ if (($ENV{PLACK_ENV} || '') eq 'development') {
+ my $class = ref($self);
+ warn "WARNING: Automatically converting $class instance to a PSGI code reference. " .
+ "If you see this warning for each request, you probably need to explicitly call " .
+ "to_app() i.e. $class->new(...)->to_app in your PSGI file.\n";
+ }
+ $self->to_app(@_);
+}
+
# NOTE:
# this is for back-compat only,
# future modules should use
View
@@ -21,7 +21,7 @@ sub new {
sub build(&;$) {
my $block = shift;
my $app = shift || sub { };
- return sub { Plack::Util::convert_to_app($block->($app->())) };
+ return sub { $block->($app->()) };
}
sub parse_options {
View
@@ -136,19 +136,6 @@ sub load_psgi {
return $app;
}
-sub convert_to_app {
- my $app = shift;
-
- if (Scalar::Util::blessed($app) && overload::Method($app, '&{}')) {
- if (($ENV{PLACK_ENV} || '') eq 'development') {
- warn "WARNING: Converting $app to PSGI code reference using &{} overloading. You probably forgot to call ->to_app etc. in your .psgi file!\n";
- }
- $app = \&$app;
- }
-
- $app;
-}
-
sub run_app($$) {
my($app, $env) = @_;

0 comments on commit 4a7e5a4

Please sign in to comment.