throw more helpful errors
groditi [Tue, 16 Jun 2009 20:49:10 +0000 (20:49 +0000)]
lib/Reaction/InterfaceModel/Action/Role/SimpleMethodCall.pm

index 285ddb1..4066d3c 100644 (file)
@@ -1,14 +1,19 @@
 package Reaction::InterfaceModel::Action::Role::SimpleMethodCall;
 
 use Reaction::Role;
-
+use Scalar::Util 'blessed';
 requires '_target_model_method';
 
 sub can_apply { 1; }
 
 sub do_apply {
   my ($self) = @_;
-  $self->target_model->${\$self->_target_model_method};
+  my $object = $self->target_model;
+  my $method_name = $self->_target_model_method;
+  if(my $method_ref = $object->can($method_name)){
+    return $object->$method_ref();
+  }
+  confess("Object ".blessed($object)." doesn't support method ${method_name}");
 }
 
 1;