AttrContainer and additional dep for it
Guillermo Roditi [Mon, 23 Jun 2008 20:58:30 +0000 (20:58 +0000)]
r16972@martha (orig r7495):  groditi | 2008-03-14 18:25:44 -0400

Makefile.PL
lib/Catalyst/AttrContainer.pm

index ab5e7c6..d183865 100644 (file)
@@ -1,11 +1,15 @@
 use inc::Module::Install 0.64;
 
-use 5.008001; 
+use 5.008001;
 perl_version '5.8.1';
 
 name 'Catalyst-Runtime';
 all_from 'lib/Catalyst/Runtime.pm';
 
+#from Moose port:
+requires 'Moose'; #version tbd.
+requires 'MooseX::ClassAttribute'; #version tbd
+
 requires 'perl'               => '5.8.1';
 requires 'Carp';
 requires 'Class::Accessor::Fast';
@@ -38,7 +42,7 @@ if (-e 'inc/.author') {
   build_requires 'Test::Pod' => 1.14;
   build_requires 'Test::Pod::Coverage' => 1.04;
 
-  if ($^O eq 'darwin') { 
+  if ($^O eq 'darwin') {
       my $osx_ver = `/usr/bin/sw_vers -productVersion`;
       chomp $osx_ver;
 
@@ -48,7 +52,7 @@ if (-e 'inc/.author') {
 
       makemaker_args(dist => { PREOP => qq{\@if [ "\$\$$attr" != "true" ]; then}.
                                         qq{ echo "You must set the ENV variable $attr to true,"; }.
-                                        ' echo "to avoid getting resource forks in your dist."; exit 255; fi' }); 
+                                        ' echo "to avoid getting resource forks in your dist."; exit 255; fi' });
   }
 }
 
@@ -68,7 +72,7 @@ print <<"EOF";
         perl -MCPANPLUS -e 'install Catalyst::Devel' # or
         perl -MCPAN -e 'install Catalyst::Devel'
 
-    To get some commonly used plugins, as well as the TT view and DBIC 
+    To get some commonly used plugins, as well as the TT view and DBIC
     model, install Task::Catalyst in the same way.
 
  Have fun!
index a33d822..dae87dc 100644 (file)
@@ -1,19 +1,28 @@
 package Catalyst::AttrContainer;
 
-use strict;
-use base qw/Class::Accessor::Fast Class::Data::Inheritable/;
-
+use Moose;
+use MooseX::ClassAttribute;
 use Catalyst::Exception;
-use NEXT;
 
-__PACKAGE__->mk_classdata($_) for qw/_attr_cache _action_cache/;
-__PACKAGE__->_attr_cache( {} );
-__PACKAGE__->_action_cache( [] );
+class_has _attr_cache   => (
+                            is => 'rw',
+                            isa => 'HashRef',
+                            required => 1,
+                            default => sub{{}}
+                           );
+clas_has _action_cache => (
+                           is => 'rw',
+                           isa => 'ArrayRef',
+                           required => 1,
+                           default => sub{ [] }
+                          );
 
 # note - see attributes(3pm)
 sub MODIFY_CODE_ATTRIBUTES {
     my ( $class, $code, @attrs ) = @_;
+    #can't the below just be $class->_attr_cache->{$code} = \@attrs; ?
     $class->_attr_cache( { %{ $class->_attr_cache }, $code => [@attrs] } );
+    #why can't this just be push @{$class->_action_cache}, [$code, \@attrs] ?
     $class->_action_cache(
         [ @{ $class->_action_cache }, [ $code, [@attrs] ] ] );
     return ();
@@ -29,7 +38,7 @@ Catalyst::AttrContainer
 
 =head1 DESCRIPTION
 
-This class sets up the code attribute cache.  It's a base class for 
+This class sets up the code attribute cache.  It's a base class for
 L<Catalyst::Controller>.
 
 =head1 METHODS