with 'CatalystX::DynamicComponent' => {
name => '_setup_dynamic_controller',
+ roles => ['CatalystX::ModelToControllerReflector::ControllerRole'],
};
requires 'setup_components';
my $config_name = $controller_name;
$config_name =~ s/^[^:]+:://;
- my $config = $app->config->{$config_name};
- my @roles = @{ $config->{roles}||[] };
- @roles = uniq @roles, 'CatalystX::ModelToControllerReflector::ControllerRole';
- $config->{roles} = \@roles;
+
+ # Shallow copy so we don't stuff method refs in config
+ my $config = { %{$app->config->{$config_name}} };
+
$config->{methods} = \%controller_methods;
$app->_setup_dynamic_controller( $controller_name, $config );
}
# forced to do it globally.
with 'CatalystX::DynamicComponent' => {
name => '_setup_dynamic_model',
- COMPONENT => sub {
- my ($component_class_name, $app, $args) = @_;
+ methods => {
+ COMPONENT => sub {
+ my ($component_class_name, $app, $args) = @_;
- my $class = delete $args->{class};
- Class::MOP::load_class($class);
+ my $class = delete $args->{class};
+ Class::MOP::load_class($class);
- $class->new($args);
+ $class->new($args);
+ },
},
};