1 package DBIx::Class::Storage::TxnScopeGuard;
7 my ($class, $storage) = @_;
10 bless [ 0, $storage ], ref $class || $class;
16 $self->[1]->txn_commit;
21 my ($dismiss, $storage) = @{$_[0]};
23 $storage->txn_rollback unless $dismiss;
32 DBIx::Class::Storage::TxnScopeGuard
37 my ($self, $schema) = @_;
39 my $guard = $schema->txn_scope_guard;
41 # Multiple database operations here
48 An object that behaves much like L<Scope::Guard>, but hardcoded to do the
49 right thing with transactions in DBIx::Class.
55 Creating an instance of this class will start a new transaction. Expects a
56 L<DBIx::Class::Storage> object as its only argument.
60 Commit the transaction, and stop guarding the scope. If this method is not
61 called (i.e. an exception is thrown) and this object goes out of scope then
62 the transaction is rolled back.
68 L<DBIx::Class::Schema/txn_scope_guard>.
74 Insipred by L<Scope::Guard> by chocolateboy.
76 This module is free software. It may be used, redistributed and/or modified
77 under the same terms as Perl itself.