[Catalyst-commits] r7988 - in Catalyst-Runtime/5.80/trunk: . lib/Catalyst t

groditi at dev.catalyst.perl.org groditi at dev.catalyst.perl.org
Mon Jun 23 22:20:41 BST 2008


Author: groditi
Date: 2008-06-23 22:20:41 +0100 (Mon, 23 Jun 2008)
New Revision: 7988

Added:
   Catalyst-Runtime/5.80/trunk/t/unit_core_component_mro.t
Modified:
   Catalyst-Runtime/5.80/trunk/
   Catalyst-Runtime/5.80/trunk/lib/Catalyst/Component.pm
Log:
 r18399 at martha (orig r7893):  groditi | 2008-06-04 12:15:25 -0400
 backcompat for NEXT in &COMPONENT + test



Property changes on: Catalyst-Runtime/5.80/trunk
___________________________________________________________________
Name: svk:merge
   - 1c72fc7c-9ce4-42af-bf25-3bfe470ff1e8:/local/Catalyst/trunk/Catalyst-Runtime:9763
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.70/trunk:7576
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/moose:7827
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-ChildOf:4443
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-Runtime-jrockway:5857
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-component-setup:4320
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-docs:4325
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/current/Catalyst-Runtime:5142
4ad37cd2-5fec-0310-835f-b3785c72a374:/trunk/Catalyst:4483
4ad37cd2-5fec-0310-835f-b3785c72a374:/trunk/Catalyst-Runtime:6165
d7608cd0-831c-0410-93c0-e5b306c3c028:/local/Catalyst/Catalyst-Runtime:8339
d7608cd0-831c-0410-93c0-e5b306c3c028:/local/Catalyst/Catalyst-Runtime-jrockway:8342
e56d974f-7718-0410-8b1c-b347a71765b2:/local/Catalyst-Runtime:6511
e56d974f-7718-0410-8b1c-b347a71765b2:/local/Catalyst-Runtime-current:10442
   + 1c72fc7c-9ce4-42af-bf25-3bfe470ff1e8:/local/Catalyst/trunk/Catalyst-Runtime:9763
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.70/trunk:7576
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/moose:7893
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-ChildOf:4443
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-Runtime-jrockway:5857
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-component-setup:4320
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-docs:4325
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/current/Catalyst-Runtime:5142
4ad37cd2-5fec-0310-835f-b3785c72a374:/trunk/Catalyst:4483
4ad37cd2-5fec-0310-835f-b3785c72a374:/trunk/Catalyst-Runtime:6165
d7608cd0-831c-0410-93c0-e5b306c3c028:/local/Catalyst/Catalyst-Runtime:8339
d7608cd0-831c-0410-93c0-e5b306c3c028:/local/Catalyst/Catalyst-Runtime-jrockway:8342
e56d974f-7718-0410-8b1c-b347a71765b2:/local/Catalyst-Runtime:6511
e56d974f-7718-0410-8b1c-b347a71765b2:/local/Catalyst-Runtime-current:10442

Modified: Catalyst-Runtime/5.80/trunk/lib/Catalyst/Component.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/lib/Catalyst/Component.pm	2008-06-23 21:20:34 UTC (rev 7987)
+++ Catalyst-Runtime/5.80/trunk/lib/Catalyst/Component.pm	2008-06-23 21:20:41 UTC (rev 7988)
@@ -1,8 +1,11 @@
 package Catalyst::Component;
 
 use Moose;
+use Class::MOP;
 use MooseX::Adopt::Class::Accessor::Fast;
 use Catalyst::Utils;
+use MRO::Compat;
+use mro 'c3';
 
 with 'MooseX::Emulate::Class::Accessor::Fast';
 with 'Catalyst::ClassData';
@@ -70,6 +73,12 @@
 
     # Temporary fix, some components does not pass context to constructor
     my $arguments = ( ref( $_[-1] ) eq 'HASH' ) ? $_[-1] : {};
+    if( my $next = $self->next::can ){
+      my $class = blessed $self || $self;
+      my ($next_package) = Class::MOP::get_code_info($next);
+      warn "There is a COMPONENT method resolving after Catalyst::Component in ${next_package}. This behavior is deprecated and will stop working in future releases.";
+      return $next->($self, $arguments);
+    }
     return $self->new($c, $arguments);
 }
 

Added: Catalyst-Runtime/5.80/trunk/t/unit_core_component_mro.t
===================================================================
--- Catalyst-Runtime/5.80/trunk/t/unit_core_component_mro.t	                        (rev 0)
+++ Catalyst-Runtime/5.80/trunk/t/unit_core_component_mro.t	2008-06-23 21:20:41 UTC (rev 7988)
@@ -0,0 +1,26 @@
+use Test::More tests => 2;
+use strict;
+use warnings;
+
+{
+  package MyApp::Component;
+  use Test::More;
+
+  sub COMPONENT{
+    my $caller = caller;
+    is($caller, 'Catalyst::Component', 'Correct method resolution');
+  }
+
+  package MyApp::MyComponent;
+
+  use base 'Catalyst::Component', 'MyApp::Component';
+
+}
+
+{
+  my $expects = qr/after Catalyst::Component in MyApp::Component/;
+  local $SIG{__WARN__} = sub {
+    like($_[0], $expects, 'correct warning thrown');
+  };
+  MyApp::MyComponent->COMPONENT('MyApp');
+}




More information about the Catalyst-commits mailing list