I still haven't gotten this :)
[catagits/Catalyst-Runtime.git] / lib / Catalyst / IOC / LifeCycle / Request.pm
index 76806d7..170ded3 100644 (file)
@@ -1,21 +1,26 @@
 package Catalyst::IOC::LifeCycle::Request;
 use Moose::Role;
 use namespace::autoclean;
-use Carp;
 with 'Bread::Board::LifeCycle';
 
 around get => sub {
-    my $orig = shift;
-    my $self = shift;
+    my $orig   = shift;
+    my $self   = shift;
+    my $params = {@_};
 
-    my $instance = $self->$orig(@_);
+    my $ctx = exists $params->{ctx} && ref $params->{ctx}
+            ? $params->{ctx}
+            : undef
+            ;
 
-    my $ctx = $self->param('ctx')
-        or confess qq/This component has a Request lifecycle.\n/ .
-                   qq/The 'ctx' parameter is mandatory./;
+    # FIXME - this makes absolutely no sense
+    # dispatcher wants the object (through container->get_all_components)
+    # but doesn't have the context. Builder *needs* the context!!
+    # What to do???
+    return $self->$orig(@_) unless $ctx;
 
     my $stash_key = "__Catalyst_IOC_LifeCycle_Request_" . $self->name;
-    return $ctx->stash->{$stash_key} ||= $instance;
+    return $ctx->stash->{$stash_key} ||= $self->$orig(@_);
 };
 
 1;