use Moose;
use Class::MOP;
-with 'MooseX::Emulate::Class::Accessor::Fast';
+with 'MooseX::Emulate::Class::Accessor::Fast' => { excludes => [ 'BUILD' ] };
use Catalyst::Exception;
use Catalyst::Utils;
use Tree::Simple;
use Tree::Simple::Visitor::FindByPath;
+
# Refactoring note:
# do these belong as package vars or should we build these via a builder method?
# See Catalyst-Plugin-Server for them being added to, which should be much less ugly.
sub forward {
my $self = shift;
+ no warnings 'recursion';
$self->_do_forward(forward => @_);
}
return 0;
}
- no warnings 'recursion';
local $c->request->{arguments} = $args;
+ no warnings 'recursion';
$action->dispatch( $c );
return $c->state;
}
}
-sub _find_component_class {
+sub _find_component {
my ( $self, $c, $component ) = @_;
- return ref($component)
- || ref( $c->component($component) )
- || $c->component($component);
+ # fugly, why doesn't ->component('MyApp') work?
+ return $c if ($component eq blessed($c));
+
+ return blessed($component)
+ ? $component
+ : $c->component($component);
}
sub _invoke_as_component {
- my ( $self, $c, $component, $method ) = @_;
+ my ( $self, $c, $component_or_class, $method ) = @_;
- my $class = $self->_find_component_class( $c, $component ) || return 0;
+ my $component = $self->_find_component($c, $component_or_class);
+ my $component_class = blessed $component || return 0;
- if (my $code = $component_instance->can('action_for')) {
- my $possible_action = $component_instance->$code($method);
+ if (my $code = $component_class->can('action_for')) {
+ my $possible_action = $component->$code($method);
return $possible_action if $possible_action;
}
- if ( my $code = $class->can($method) ) {
+ if ( my $code = $component_class->can($method) ) {
return $self->_method_action_class->new(
{
name => $method,
code => $code,
- reverse => "$class->$method",
- class => $class,
+ reverse => "$component_class->$method",
+ class => $component_class,
namespace => Catalyst::Utils::class2prefix(
- $class, $c->config->{case_sensitive}
+ $component_class, $c->config->{case_sensitive}
),
}
);
}
else {
my $error =
- qq/Couldn't forward to "$class". Does not implement "$method"/;
+ qq/Couldn't forward to "$component_class". Does not implement "$method"/;
$c->error($error);
$c->log->debug($error)
if $c->debug;
=head2 $self->get_action_by_path( $path );
-Returns the named action by its full path.
+Returns the named action by its full private path.
=cut
return @loaded;
}
-# Dont document this until someone else is happy with beaviour. Ash 2009/03/16
+=head2 $self->dispatch_type( $type )
+
+Get the DispatchType object of the relevant type, i.e. passing C<$type> of
+C<Chained> would return a L<Catalyst::DispatchType::Chained> object (assuming
+of course it's being used.)
+
+=cut
+
sub dispatch_type {
my ($self, $name) = @_;