[Dbix-class] Shortcut to get to schema from rows?
Toby Corkindale
toby.corkindale at strategicdata.com.au
Tue Apr 7 06:08:45 GMT 2009
Hi,
I find myself doing the following in my table classes often, and
wondered if there's a more elegant way?
package MyApp::Schema::Foo;
__PACKAGE__->table('foo');
...
sub frobnicate {
my $self = shift;
$self->result_source->schema->txn_do(
sub {
$self->some_relationship->do_stuff;
$self->another_thing->do_stuff;
$self->status('frobnicated');
}
);
return $self;
}
So really I just wondered if txn_do() was available at a closer level?
I mean, there's nothing stopping me making my table classes inherit from
a base class which look like the following, but I figured maybe you'd
already implemented something like it?
package MyApp::TableBaseClass;
sub txn {
return shift->result_source->schema->txn_do(@_);
}
Cheers!
Toby
More information about the DBIx-Class
mailing list