Initial support for :Args attribute
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Action.pm
index 130006a..8e5ea75 100644 (file)
@@ -13,6 +13,9 @@ use overload (
     # Codulate to encapsulated action coderef
     '&{}' => sub { shift->{code} },
 
+    # Make general $stuff still work
+    fallback => 1,
+
 );
 
 =head1 NAME
@@ -43,6 +46,16 @@ sub execute {    # Execute ourselves against a context
     return $c->execute( $self->class, $self );
 }
 
+=head2 match
+
+=cut
+
+sub match {
+    my ( $self, $c ) = @_;
+    return 1 unless exists $self->attributes->{Args};
+    return scalar(@{$c->req->args}) == $self->attributes->{Args}[0];
+}
+
 =head2 namespace
 
 =head2 reverse