And get the other strategy from master implemented
[catagits/CatalystX-DynamicComponent.git] / lib / CatalystX / DynamicComponent / ModelToControllerReflector.pm
index 4fade17..8856e97 100644 (file)
@@ -51,13 +51,15 @@ 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;
 
     my $model_methods = $model->meta->get_method_map;
-    foreach my $method_name ( $strategy->get_reflected_method_list($app, $model->meta) ) {
+    foreach my $method_name ( $strategy->get_reflected_method_list($app, $model_name, $model) ) {
         # Note need to pass model name, as the method actually comes from
         # the underlying model class, not the Catalyst shim class we autogenerated.
         $controller_methods{$method_name} = 
@@ -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 {