Question if you have the gumption ... how would you handle loading the data?
Honestly, I would have used DBIx::Class or Fey::ORM. I wrote my own ORM years ago when SPOPS was state of the art and Class::DBI was still very much an ugly/dirty hack. I won't ever write one again, it is a solved problem and I have no interest in re-inventing that wheel.
First, it is very much not recommended to put a BUILD method in roles because it could get overridden by a local class version. You should do a before/after/around for BUILD instead, which will do what you want it to do.
Second, I would get rid of the BUILD method anyway and put the load function into the role and then call MyTable->load( id => 1 ) to get things from the DB, because using new to fetch from the database is misleading since it is not creating a new instance, but loading an old one.
In reply to Re^5: Moose + ORM
by stvn
in thread Moose + ORM
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |