Re: sth->prepare() setting Active?

David Nicol <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.dbi.general
Message-ID <CAFwScO87OpCJrGiGXYAiZuiyrUmjwtosGPeNKkKZko7kHzvWRg@mail.gmail.com>
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;
};
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.