this isn't tested -- i'm writing it here in e-mail -- but it or something
very close to it might work. supporting prepare_cached or other forms of
sth reuse could require a way to clear the flag.


package DBIx::WrapActive;
our $AUTOLOAD;

### invoke like $sth = DBIx::WrapActive::wrap($sth);
sub wrap{ bless [$_[0], 0 ] };
sub active { $_[0]->[1] and $_[0]->active }
sub execute {
    my $obj = shift;
    $obj->[1] = 1;
    $obj->[0]->execute(@_);
}
sub AUTOLOAD{
     my ($method) = $AUTOLOAD =~ m/::([^:]+)$/;
     *{$AUTOLOAD} = sub {
         my $obj = shift;
         $obj->[0]->$method(@_);
     };
     goto &$AUTOLOAD;
};

Reply via email to