[Catalyst-commits] r8242 - in
CatalystX-CRUD/CatalystX-CRUD/trunk/lib/CatalystX/CRUD: . Test
karpet at dev.catalyst.perl.org
karpet at dev.catalyst.perl.org
Thu Aug 21 11:50:34 BST 2008
Author: karpet
Date: 2008-08-21 11:50:33 +0100 (Thu, 21 Aug 2008)
New Revision: 8242
Modified:
CatalystX-CRUD/CatalystX-CRUD/trunk/lib/CatalystX/CRUD/Model.pm
CatalystX-CRUD/CatalystX-CRUD/trunk/lib/CatalystX/CRUD/ModelAdapter.pm
CatalystX-CRUD/CatalystX-CRUD/trunk/lib/CatalystX/CRUD/Test/Controller.pm
Log:
add has_relationship() method and set res code on test errors
Modified: CatalystX-CRUD/CatalystX-CRUD/trunk/lib/CatalystX/CRUD/Model.pm
===================================================================
--- CatalystX-CRUD/CatalystX-CRUD/trunk/lib/CatalystX/CRUD/Model.pm 2008-08-21 10:44:08 UTC (rev 8241)
+++ CatalystX-CRUD/CatalystX-CRUD/trunk/lib/CatalystX/CRUD/Model.pm 2008-08-21 10:50:33 UTC (rev 8242)
@@ -257,6 +257,13 @@
It is up to the subclass to implement this method.
+=item has_relationship( I<obj>, I<rel_name> )
+
+Should return true or false as to whether I<rel_name> exists for
+I<obj>.
+
+It is up to the subclass to implement this method.
+
=back
=cut
@@ -265,6 +272,10 @@
sub add_related { shift->throw_error("must implement add_related()") }
sub rm_related { shift->throw_error("must implement rm_related()") }
+sub has_relationship {
+ shift->throw_error("must implement has_relationship()");
+}
+
1;
__END__
Modified: CatalystX-CRUD/CatalystX-CRUD/trunk/lib/CatalystX/CRUD/ModelAdapter.pm
===================================================================
--- CatalystX-CRUD/CatalystX-CRUD/trunk/lib/CatalystX/CRUD/ModelAdapter.pm 2008-08-21 10:44:08 UTC (rev 8241)
+++ CatalystX-CRUD/CatalystX-CRUD/trunk/lib/CatalystX/CRUD/ModelAdapter.pm 2008-08-21 10:50:33 UTC (rev 8242)
@@ -154,11 +154,23 @@
It is up to the subclass to implement this method.
+=head2 has_relationship( I<controller>, I<context>, I<obj>, I<rel_name> )
+
+Should return true or false as to whether I<rel_name> exists for
+I<obj>.
+
+It is up to the subclass to implement this method.
+
+
=cut
sub add_related { shift->throw_error("must implement add_related()") }
sub rm_related { shift->throw_error("must implement rm_related()") }
+sub has_relationship {
+ shift->throw_error("must implement has_relationship()");
+}
+
=head1 CRUD Methods
The following methods are implemented in CatalystX::CRUD::Object when
Modified: CatalystX-CRUD/CatalystX-CRUD/trunk/lib/CatalystX/CRUD/Test/Controller.pm
===================================================================
--- CatalystX-CRUD/CatalystX-CRUD/trunk/lib/CatalystX/CRUD/Test/Controller.pm 2008-08-21 10:44:08 UTC (rev 8241)
+++ CatalystX-CRUD/CatalystX-CRUD/trunk/lib/CatalystX/CRUD/Test/Controller.pm 2008-08-21 10:50:33 UTC (rev 8242)
@@ -133,8 +133,9 @@
if ( defined $c->stash->{object} ) {
$c->res->body( $self->serialize_object( $c, $c->stash->{object} ) );
}
- if ( @{ $c->error } ) {
+ if ( $self->has_errors($c) ) {
$c->res->body( join( "\n", @{ $c->error } ) );
+ $c->res->status(500);
$c->clear_errors;
}
}
More information about the Catalyst-commits
mailing list