http://www.perlmonks.org?node_id=139919


in reply to Refactor method calls or not?

No need to obscure things with AUTOLOAD.
%ALLOWED_TABLES = map {$_ => 1} qw(company financialDiary); sub add_data { my ( $self, $table, $data ) = @_; die "bad table!" unless $ALLOWED_TABLES{$table}; my $data = $self->_generic_insert( $data, $table ); $self->{ _dbh }->commit if ! $self->{ _error }; return $data; }
Of course you have to change your method calls, and maybe this is a problem for you.

Regarding transactions, I think the transaction control belongs in the code that is calling these methods, not in the methods themselves. These data access methods don't know anything about the context they are being called in.

UPDATE: fixed array name mismatch and changed to hash