[Catalyst-commits] r9345 - Catalyst-Runtime/5.80/branches/register_actions/lib/Catalyst

rafl at dev.catalyst.perl.org rafl at dev.catalyst.perl.org
Thu Feb 19 05:21:45 GMT 2009


Author: rafl
Date: 2009-02-19 05:21:45 +0000 (Thu, 19 Feb 2009)
New Revision: 9345

Removed:
   Catalyst-Runtime/5.80/branches/register_actions/lib/Catalyst/AttrContainer.pm
Modified:
   Catalyst-Runtime/5.80/branches/register_actions/lib/Catalyst/Controller.pm
Log:
First steps towards throwing out attributes.

Deleted: Catalyst-Runtime/5.80/branches/register_actions/lib/Catalyst/AttrContainer.pm
===================================================================
--- Catalyst-Runtime/5.80/branches/register_actions/lib/Catalyst/AttrContainer.pm	2009-02-19 05:16:12 UTC (rev 9344)
+++ Catalyst-Runtime/5.80/branches/register_actions/lib/Catalyst/AttrContainer.pm	2009-02-19 05:21:45 UTC (rev 9345)
@@ -1,60 +0,0 @@
-package Catalyst::AttrContainer;
-
-use Moose;
-use Catalyst::Exception;
-with 'Catalyst::ClassData';
-
-no Moose;
-
-__PACKAGE__->mk_classdata(_attr_cache => {} );
-__PACKAGE__->mk_classdata( _action_cache => [] );
-
-# note - see attributes(3pm)
-sub MODIFY_CODE_ATTRIBUTES {
-    my ( $class, $code, @attrs ) = @_;
-    $class->_attr_cache( { %{ $class->_attr_cache }, $code => [@attrs] } );
-    $class->_action_cache(
-        [ @{ $class->_action_cache }, [ $code, [@attrs] ] ] );
-    return ();
-}
-
-sub FETCH_CODE_ATTRIBUTES { $_[0]->_attr_cache->{ $_[1] } || () }
-
-=head1 NAME
-
-Catalyst::AttrContainer - Handles code attribute storage and caching
-
-=head1 SYNOPSIS
-
-=head1 DESCRIPTION
-
-This class sets up the code attribute cache.  It's a base class for 
-L<Catalyst::Controller>.
-
-=head1 METHODS
-
-=head2 FETCH_CODE_ATTRIBUTES
-
-Attribute function. See attributes(3pm)
-
-=head2 MODIFY_CODE_ATTRIBUTES
-
-Attribute function. See attributes(3pm)
-
-=head1 SEE ALSO
-
-L<Catalyst::Dispatcher>
-L<Catalyst>.
-
-=head1 AUTHORS
-
-Catalyst Contributors, see Catalyst.pm
-
-=head1 COPYRIGHT
-
-This program is free software, you can redistribute it and/or modify it under
-the same terms as Perl itself.
-
-=cut
-
-1;

Modified: Catalyst-Runtime/5.80/branches/register_actions/lib/Catalyst/Controller.pm
===================================================================
--- Catalyst-Runtime/5.80/branches/register_actions/lib/Catalyst/Controller.pm	2009-02-19 05:16:12 UTC (rev 9344)
+++ Catalyst-Runtime/5.80/branches/register_actions/lib/Catalyst/Controller.pm	2009-02-19 05:21:45 UTC (rev 9345)
@@ -1,12 +1,11 @@
 package Catalyst::Controller;
 
 use Moose;
-use Moose::Util qw/find_meta/;
+use Moose::Util qw/find_meta does_role/;
 
 use namespace::clean -except => 'meta';
 
-# Note - Must be done at compile time due to attributes (::AttrContainer)
-BEGIN { extends qw/Catalyst::Component Catalyst::AttrContainer/; }
+BEGIN { extends qw/Catalyst::Component MooseX::MethodAttributes::Inheritable/; }
 
 use Catalyst::Exception;
 use Catalyst::Utils;
@@ -182,34 +181,25 @@
     #this is still not correct for some reason.
     my $namespace = $self->action_namespace($c);
     my $meta = find_meta($self);
-    my %methods = map { $_->body => $_->name }
+    my @methods = grep { does_role($_, 'MooseX::MethodAttributes::Role::Meta::Method') }
             $meta->get_all_methods;
 
-    # Advanced inheritance support for plugins and the like
-    #moose todo: migrate to eliminate CDI compat
-    my @action_cache;
-    for my $isa ( $meta->superclasses, $class ) {
-        if(my $coderef = $isa->can('_action_cache')){
-            push(@action_cache, @{ $isa->$coderef });
-        }
-    }
-
-    foreach my $cache (@action_cache) {
-        my $code   = $cache->[0];
-        my $method = delete $methods{$code}; # avoid dupe registers
-        next unless $method;
-        my $attrs = $self->_parse_attrs( $c, $method, @{ $cache->[1] } );
+    foreach my $method (@methods) {
+        my $name = $method->name;
+        my $attributes = $method->attributes;
+        next unless $attributes;
+        my $attrs = $self->_parse_attrs( $c, $name, @{ $attributes } );
         if ( $attrs->{Private} && ( keys %$attrs > 1 ) ) {
             $c->log->debug( 'Bad action definition "'
-                  . join( ' ', @{ $cache->[1] } )
-                  . qq/" for "$class->$method"/ )
+                  . join( ' ', @{ $attributes } )
+                  . qq/" for "$class->$name"/ )
               if $c->debug;
             next;
         }
         my $reverse = $namespace ? "${namespace}/${method}" : $method;
         my $action = $self->create_action(
-            name       => $method,
-            code       => $code,
+            name       => $name,
+            code       => $method->body,
             reverse    => $reverse,
             namespace  => $namespace,
             class      => $class,




More information about the Catalyst-commits mailing list