X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalystX%2FDynamicComponent%2FModelToControllerReflector.pm;fp=lib%2FCatalystX%2FDynamicComponent%2FModelToControllerReflector.pm;h=01883b5c75e19ed408b219b7021fa8f7aa4c0727;hb=84d8e4e1c7c3b67669a0ac8dac75b5a2f927dfeb;hp=4fade17f0bedbce919696d4d3e21a3613c580d04;hpb=f38d3061acf7d7abf266fecf958b9a138b7e7224;p=catagits%2FCatalystX-DynamicComponent.git diff --git a/lib/CatalystX/DynamicComponent/ModelToControllerReflector.pm b/lib/CatalystX/DynamicComponent/ModelToControllerReflector.pm index 4fade17..01883b5 100644 --- a/lib/CatalystX/DynamicComponent/ModelToControllerReflector.pm +++ b/lib/CatalystX/DynamicComponent/ModelToControllerReflector.pm @@ -51,7 +51,9 @@ sub _reflect_model_to_controller { my %controller_methods; # FIXME - Abstract this strategy crap out. - my $strategy = $app->config->{'CatalystX::DynamicComponent::ModelToControllerReflector'}{'reflection_strategy'} || 'InterfaceRoles'; + my $config = exists $app->config->{'CatalystX::DynamicComponent::ModelToControllerReflector'} + ? $app->config->{'CatalystX::DynamicComponent::ModelToControllerReflector'} : {}; + my $strategy = exists $config->{reflection_strategy} ? $config->{reflection_strategy} : 'InterfaceRoles'; $strategy = "CatalystX::DynamicComponent::ModelToControllerReflector::Strategy::$strategy"; Class::MOP::load_class($strategy); $strategy->new; @@ -65,10 +67,10 @@ sub _reflect_model_to_controller { } # Shallow copy so we don't stuff method refs in config - my $config = { %{$app->config->{$controller_name}||{}} }; + my $controller_config = { %{$app->config->{$controller_name}||{}} }; - $config->{methods} = \%controller_methods; - $app->_setup_dynamic_controller( $controller_name, $config ); + $controller_config->{methods} = \%controller_methods; + $app->_setup_dynamic_controller( $controller_name, $controller_config ); } sub generate_reflected_controller_action_method {