Permalink
Browse files

Remove `with`.

  • Loading branch information...
1 parent 48729c3 commit 6717f101ac29d2000992b83e3553765f84a316dc @theory committed Sep 27, 2011
Showing with 2 additions and 107 deletions.
  1. +2 −0 Changes
  2. +0 −61 lib/DBIx/Connector.pm
  3. +0 −46 t/with.t
View
@@ -4,6 +4,8 @@ Revision history for Perl extension DBIx::Connector.
- The `catch` functionality has been completely removed. Any `catch`
block passed to `run()`, `txn()`, or `svp()` will be ignored. Errors
will trigger fatal exceptions.
+ - Removed the `with` method, which was deprecated in 0.34. Use `mode()`
+ instead.
0.47 2011-09-26T17:12:07Z
- Use of the deprecated `catch` functionality now warns on every call,
View
@@ -323,12 +323,6 @@ PROXY: {
}
}
-sub with {
- Carp::carp("DBIx::Connector->with is deprecated. Set the 'mode' attribute instead")
- unless $ENV{DBICONNTEST};
- DBIx::Connector::Proxy->new(@_)
-}
-
sub _exec {
my ($dbh, $code, $wantarray) = @_;
local $_ = $dbh;
@@ -858,61 +852,6 @@ or C<svp()>, the mode attribute will be set to the optional first parameter:
In this way, you can reliably tell in what mode the code block is executing.
-=head3 C<with>
-
- $conn->with('fixup')->txn(sub {
- $_->do('UPDATE users SET active = true' );
- })
-
-B<DEPRECATED.> Will be removed in a future version. Use the C<mode> accessor,
-instead.
-
-Constructs and returns a proxy object that delegates calls to
-L<C<run()>|/"run">, L<C<txn()>|/"txn">, and L<C<svp()>|/"svp"> with a default
-L<connection mode|/"Connection Modes">. This can be useful if you always use
-the same mode and don't want to always have to be passing it as the first
-argument to those methods:
-
- my $proxy = $conn->with('fixup');
-
- # ... later ...
- $proxy->run( sub { $proxy->dbh->do('SELECT update_bar()') } );
-
-This is mainly designed for use by ORMs and other database tools that need to
-require a default connection mode. But others may find it useful as well.
-The proxy object offers the following methods:
-
-=over
-
-=item C<conn>
-
-The original DBIx::Connector object.
-
-=item C<mode>
-
-The mode that will be passed to the block execution methods.
-
-=item C<dbh>
-
-Dispatches to the connection's C<dbh()> method.
-
-=item C<run>
-
-Dispatches to the connection's C<run()> method, with the C<mode> preferred
-mode.
-
-=item C<txn>
-
-Dispatches to the connection's C<txn()> method, with the C<mode> preferred
-mode.
-
-=item C<svp>
-
-Dispatches to the connection's C<svp()> method, with the C<mode> preferred
-mode.
-
-=back
-
=head3 C<connected>
if ( $conn->connected ) {
View
@@ -1,46 +0,0 @@
-#!/usr/bin/env perl -w
-
-use strict;
-use warnings;
-use Test::More tests => 81;
-#use Test::More 'no_plan';
-use Test::MockModule;
-
-my $CLASS;
-BEGIN {
- $CLASS = 'DBIx::Connector';
- use_ok $CLASS or die;
- $ENV{DBICONNTEST} = 1;
-}
-
-ok my $conn = $CLASS->new( 'dbi:ExampleP:dummy', '', '' ),
- 'Construct connector';
-
-eval { $conn->with };
-ok my $err = $@, 'Should get an error';
-like $err, qr/Missing required mode argument/,
- 'It should be the missing mode error';
-
-eval { $conn->with('foo') };
-ok $err = $@, 'Should get an error';
-like $err, qr/Invalid mode: "foo"/, 'It should be the invalid mode error';
-
-my $mocker = Test::MockModule->new($CLASS);
-for my $mode (qw(fixup ping no_ping)) {
- ok my $proxy = $conn->with( $mode ), "Create a $mode proxy";
- isa_ok $proxy, 'DBIx::Connector::Proxy', "The $mode proxy";
- is $proxy->conn, $conn, "$mode proxy should have stored the connector";
- is $proxy->mode, $mode, "$mode proxy should have stored the mode";
-
- for my $meth (qw(run txn svp)) {
- $mocker->mock($meth => sub {
- is shift, $conn, "... Proxy $meth call should dispatch to conn $meth";
- is shift, $mode, "... Mode $meth should have been passed to $meth";
- });
- is $proxy->dbh, $conn->dbh, '... Should get the connection dbh';
- ok $proxy->$meth( sub { } ), "Call $meth";
- ok $conn->with($mode)->$meth( sub { } ), "Call $meth on new proxy";
- }
-}
-
-

0 comments on commit 6717f10

Please sign in to comment.