Subject: | Add new_with_dbh method |
I've been using DBIx::AnyDBD to build DBIx::SQLEngine, and it's been lovely -- thanks!
Based on a user request coded up a method that seemed like it might be a natural fit to add to your module. Specifically, I've received a request to allow someone to instantiate an object around an existing DBI database handle.
Looking at the code, this could be done with a method more or less as follows:
sub new_with_dbh {
my ($class, $dbh, $package) = @_;
my $self = bless { 'package'=>$package, 'dbh'=>$dbh }, $class;
$self->rebless;
$self->_init if $self->can('_init');
return $self;
}
This is effectively the same as the last four lines of the new() and connect() subs, which could be refactored to call this method instead.
Of course, I can do all of this from within my package, so it's not a real limitation, but as I say, it did seem like a natural suggestion to pass along for your consideration; I would imagine that there are some other users out there who might find this valuable as well.