[Catalyst-commits] r7689 -
CatalystX-CRUD/CatalystX-CRUD/trunk/lib/CatalystX/CRUD
karpet at dev.catalyst.perl.org
karpet at dev.catalyst.perl.org
Tue May 6 19:52:40 BST 2008
Author: karpet
Date: 2008-05-06 19:52:40 +0100 (Tue, 06 May 2008)
New Revision: 7689
Modified:
CatalystX-CRUD/CatalystX-CRUD/trunk/lib/CatalystX/CRUD/Controller.pm
Log:
call model_adapter method, not object method, where appropriate
Modified: CatalystX-CRUD/CatalystX-CRUD/trunk/lib/CatalystX/CRUD/Controller.pm
===================================================================
--- CatalystX-CRUD/CatalystX-CRUD/trunk/lib/CatalystX/CRUD/Controller.pm 2008-05-06 18:36:51 UTC (rev 7688)
+++ CatalystX-CRUD/CatalystX-CRUD/trunk/lib/CatalystX/CRUD/Controller.pm 2008-05-06 18:52:40 UTC (rev 7689)
@@ -478,15 +478,21 @@
=head2 save_obj( I<context>, I<object> )
-Calls the update() or create() method on the I<object>, picking the method
-based on whether C<object_id> in stash() evaluates true (update) or false (create).
+Calls the update() or create() method on the I<object> (or model_adapter()),
+picking the method based on whether C<object_id> in stash()
+evaluates true (update) or false (create).
=cut
sub save_obj {
my ( $self, $c, $obj ) = @_;
my $method = $c->stash->{object_id} ? 'update' : 'create';
- $obj->$method;
+ if ( $self->model_adapter ) {
+ $self->model_adapter->$method( $c, $obj );
+ }
+ else {
+ $obj->$method;
+ }
}
=head2 precommit( I<context>, I<object> )
More information about the Catalyst-commits
mailing list