in reply to Re^4: Moose + ORM
in thread Moose + ORM
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: Moose + ORM
by Anonymous Monk on Jul 24, 2009 at 20:38 UTC | |
by stvn (Monsignor) on Jul 24, 2009 at 21:02 UTC | |
by Anonymous Monk on Jul 27, 2009 at 14:29 UTC | |
by Anonymous Monk on Aug 05, 2009 at 20:12 UTC | |
by Anonymous Monk on Aug 05, 2009 at 20:14 UTC |