Initial support for :Args attribute
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Action.pm
index 807a6db..8e5ea75 100644 (file)
@@ -3,7 +3,7 @@ package Catalyst::Action;
 use strict;
 use base qw/Class::Accessor::Fast/;
 
-__PACKAGE__->mk_accessors(qw/code namespace reverse prefix attributes/);
+__PACKAGE__->mk_accessors(qw/class namespace reverse attributes name code/);
 
 use overload (
 
@@ -13,6 +13,9 @@ use overload (
     # Codulate to encapsulated action coderef
     '&{}' => sub { shift->{code} },
 
+    # Make general $stuff still work
+    fallback => 1,
+
 );
 
 =head1 NAME
@@ -27,35 +30,37 @@ See L<Catalyst>.
 
 =head1 METHODS
 
-=over 4
+=head2 attributes
 
-=item attributes
+=head2 class
 
-=item code
+=head2 code
 
-=item execute
+=head2 execute
 
 =cut
 
 sub execute {    # Execute ourselves against a context
     my ( $self, $c ) = @_;
-    return $c->execute( $self->namespace, $self );
+    local $c->namespace = $self->namespace;
+    return $c->execute( $self->class, $self );
 }
 
-=item namespace
-
-=item reverse
-
-=item new
+=head2 match
 
 =cut
 
-sub new {        # Dumbass constructor
-    my ( $class, $attrs ) = @_;
-    return bless { %{ $attrs || {} } }, $class;
+sub match {
+    my ( $self, $c ) = @_;
+    return 1 unless exists $self->attributes->{Args};
+    return scalar(@{$c->req->args}) == $self->attributes->{Args}[0];
 }
 
-=back
+=head2 namespace
+
+=head2 reverse
+
+=head2 name
 
 =head1 AUTHOR