[Catalyst-commits] r8945 - in
Catalyst-Runtime/5.80/trunk/lib/Catalyst: . Component Component/Role
rafl at dev.catalyst.perl.org
rafl at dev.catalyst.perl.org
Fri Dec 26 00:28:51 GMT 2008
Author: rafl
Date: 2008-12-26 00:28:51 +0000 (Fri, 26 Dec 2008)
New Revision: 8945
Added:
Catalyst-Runtime/5.80/trunk/lib/Catalyst/Component/
Catalyst-Runtime/5.80/trunk/lib/Catalyst/Component/Role/
Catalyst-Runtime/5.80/trunk/lib/Catalyst/Component/Role/CaptureApp.pm
Modified:
Catalyst-Runtime/5.80/trunk/lib/Catalyst/Controller.pm
Log:
Refactor capturing of $app from ::Controller into ::Component::Role::CaptureApp for easier reuse in other components.
Added: Catalyst-Runtime/5.80/trunk/lib/Catalyst/Component/Role/CaptureApp.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/lib/Catalyst/Component/Role/CaptureApp.pm (rev 0)
+++ Catalyst-Runtime/5.80/trunk/lib/Catalyst/Component/Role/CaptureApp.pm 2008-12-26 00:28:51 UTC (rev 8945)
@@ -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;
Modified: Catalyst-Runtime/5.80/trunk/lib/Catalyst/Controller.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/lib/Catalyst/Controller.pm 2008-12-25 21:18:01 UTC (rev 8944)
+++ Catalyst-Runtime/5.80/trunk/lib/Catalyst/Controller.pm 2008-12-26 00:28:51 UTC (rev 8945)
@@ -9,6 +9,8 @@
use Catalyst::Exception;
use Catalyst::Utils;
+with 'Catalyst::Component::Role::CaptureApp';
+
has path_prefix =>
(
is => 'rw',
@@ -32,20 +34,6 @@
init_arg => undef,
);
-# 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;
-};
-
sub BUILD {
my ($self, $args) = @_;
my $action = delete $args->{action} || {};
More information about the Catalyst-commits
mailing list