Refactor capturing of $app from ::Controller into ::Component::Role::CaptureApp for...
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Component / Role / CaptureApp.pm
diff --git a/lib/Catalyst/Component/Role/CaptureApp.pm b/lib/Catalyst/Component/Role/CaptureApp.pm
new file mode 100644 (file)
index 0000000..205370e
--- /dev/null
@@ -0,0 +1,20 @@
+package Catalyst::Component::Role::CaptureApp;
+
+use Moose::Role;
+use namespace::clean -except => 'meta';
+
+# Future - isa => 'ClassName|Catalyst' performance?
+#           required => 1 breaks tests..
+has _application => (is => 'ro');
+sub _app { (shift)->_application(@_) }
+
+override BUILDARGS => sub {
+    my ($self, $app) = @_;
+
+    my $args = super();
+    $args->{_application} = $app;
+
+    return $args;
+};
+
+1;