# note - see attributes(3pm)
sub MODIFY_CODE_ATTRIBUTES {
my ( $class, $code, @attrs ) = @_;
- return if ( ( $attrs[0] eq 'lvalue' ) && ( @attrs == 1 ) );
$class->_attr_cache( { %{ $class->_attr_cache }, $code => [@attrs] } );
$class->_action_cache(
[ @{ $class->_action_cache }, [ $code, [@attrs] ] ] );
my @register;
foreach my $r ( @{ $attrs->{Path} || [] } ) {
- unless ( $r ) {
+ unless ($r) {
$r = $action->namespace;
}
elsif ( $r !~ m!^/! ) { # It's a relative path
# Register sub name as a relative path
}
- $self->register_path($c, $_, $action) for @register;
+ $self->register_path( $c, $_, $action ) for @register;
+ return 1 if @register;
+ return 0;
}
=item $self->register_path($c, $path, $action)
=cut
sub register_path {
- my ($self, $c, $path, $action) = @_;
+ my ( $self, $c, $path, $action ) = @_;
$path =~ s!^/!!;
$self->{paths}{$path} = $action;
}
my ( $self, $c ) = @_;
my $re = Text::SimpleTable->new( [ 36, 'Regex' ], [ 37, 'Private' ] );
for my $regex ( @{ $self->{compiled} } ) {
- my $action = $regex->{action};
+ my $action = $regex->{action};
$re->row( $regex->{path}, "/$action" );
}
$c->log->debug( "Loaded Regex actions:\n" . $re->draw )
$self->register_path( $c, $r, $action );
$self->register_regex( $c, $r, $action );
}
+ return 1 if @register;
+ return 0;
}
=item $self->register_regex($c, $re, $action)
sub register {
my ( $self, $c, $action ) = @_;
+ my $registered = $self->registered_dispatch_types;
+
+ my $priv = 0;
+ foreach my $key ( keys %{ $action->attributes } ) {
+ $priv++ if $key eq 'Private';
+ my $class = "Catalyst::DispatchType::$key";
+ unless ( $registered->{$class} ) {
+ eval "require $class";
+ push( @{ $self->dispatch_types }, $class->new ) unless $@;
+ $registered->{$class} = 1;
+ }
+ }
+
+ # Pass the action to our dispatch types so they can register it if reqd.
+ my $reg = 0;
+ foreach my $type ( @{ $self->dispatch_types } ) {
+ $reg++ if $type->register( $c, $action );
+ }
+
+ return unless $reg + $priv;
+
my $namespace = $action->namespace;
my $parent = $self->tree;
my $visitor = Tree::Simple::Visitor::FindByPath->new;
# Set the method value
$parent->getNodeValue->actions->{ $action->name } = $action;
-
- my $registered = $self->registered_dispatch_types;
-
- foreach my $key ( keys %{ $action->attributes } ) {
- my $class = "Catalyst::DispatchType::$key";
- unless ( $registered->{$class} ) {
- eval "require $class";
- push( @{ $self->dispatch_types }, $class->new ) unless $@;
- $registered->{$class} = 1;
- }
- }
-
- # Pass the action to our dispatch types so they can register it if reqd.
- foreach my $type ( @{ $self->dispatch_types } ) {
- $type->register( $c, $action );
- }
}
=item $self->setup_actions( $class, $component )