Class::DBI has a way to make this interface for your persistent objects:
$row_obj->set_field("foo");
$row_obj->get_field();
# instead of
$row_obj->field("foo");
$row->obj_field();
That's what you meant, right?
Look for mutator_name and accessor_name - this is under http://search.cpan.org/~tmtm/Class-DBI-v3.0.14/lib/Class/DBI.pm#Changing_Your_Column_Accessor_Method_Names.
Specifically, look at
sub mutator_name_for {
my ($class, $column) = @_;
return "set_" . $column->accessor;
}
And copy over the implementation of the code that uses mutator_name to create write only accessors and readonly accessors.
|