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