aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Reaction/UI/Controller/Collection.pm
diff options
context:
space:
mode:
authort0m <t0m@03d0b0b2-0e1a-0410-a411-fdb2f4bd65d7>2008-11-25 02:17:51 +0000
committert0m <t0m@03d0b0b2-0e1a-0410-a411-fdb2f4bd65d7>2008-11-25 02:17:51 +0000
commit09d2d18d3ee75780b3c7922bb0af004cf58b4be1 (patch)
tree94579bae8a0e4ba0f3b493c02c54422040fe7e12 /lib/Reaction/UI/Controller/Collection.pm
parentdb80cb74feca3ad9f372047624ccfcdfa8122ee4 (diff)
downloadreaction-09d2d18d3ee75780b3c7922bb0af004cf58b4be1.tar.gz
reaction-09d2d18d3ee75780b3c7922bb0af004cf58b4be1.zip
Tell the user that they're an idiot in more helpful ways
Diffstat (limited to 'lib/Reaction/UI/Controller/Collection.pm')
-rw-r--r--lib/Reaction/UI/Controller/Collection.pm10
1 files changed, 7 insertions, 3 deletions
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";
}