diff options
-rw-r--r-- | lib/Reaction/InterfaceModel/Reflector/DBIC.pm | 6 | ||||
-rw-r--r-- | lib/Reaction/UI/Controller/Collection.pm | 10 |
2 files changed, 12 insertions, 4 deletions
diff --git a/lib/Reaction/InterfaceModel/Reflector/DBIC.pm b/lib/Reaction/InterfaceModel/Reflector/DBIC.pm index afa3dad..8ec01ab 100644 --- a/lib/Reaction/InterfaceModel/Reflector/DBIC.pm +++ b/lib/Reaction/InterfaceModel/Reflector/DBIC.pm @@ -650,6 +650,8 @@ sub parameters_for_source_object_attribute { my $from_attr = $source_class->meta->find_attribute_by_name($attr_name); my $reader = $from_attr->get_read_method; + die("Could not find reader for attribute '$attr_name' on $source_class") + unless $reader; #default options. lazy build but no outsider method my %attr_opts = ( is => 'ro', lazy => 1, required => 1, @@ -731,7 +733,9 @@ sub parameters_for_source_object_attribute { } else { #no rel $attr_opts{isa} = $from_attr->_isa_metadata; - $attr_opts{default} = eval "sub{ shift->${dm_name}->${reader} }"; + my $default_code = "sub{ shift->${dm_name}->${reader} }"; + $attr_opts{default} = eval $default_code; + die "Could not generate default for attribute, code '$default_code' did not compile with: $@" if $@; } return \%attr_opts; }; diff --git a/lib/Reaction/UI/Controller/Collection.pm b/lib/Reaction/UI/Controller/Collection.pm index e28fbdf..bf46580 100644 --- a/lib/Reaction/UI/Controller/Collection.pm +++ b/lib/Reaction/UI/Controller/Collection.pm @@ -85,12 +85,16 @@ sub _build_collection_action_prototype { sub get_collection { my ($self, $c) = @_; my $model = $c->model( $self->model_name ); + confess "Failed to find Catalyst model named: " . $self->model_name + unless $model; my $collection = $self->collection_name; if( my $meth = $model->can( $collection ) ){ return $model->$meth; - } elsif ( my $attr = $model->meta->find_attribute_by_name($collection) ) { - my $reader = $attr->get_read_method; - return $model->$reader; + } elsif ( my $meta = $model->can('meta') ){ + if ( my $attr = $model->$meta->find_attribute_by_name($collection) ) { + my $reader = $attr->get_read_method; + return $model->$reader; + } } confess "Failed to find collection $collection"; } |