So, I’ve been working on this Loader thing, trying to get it to write Moose attributes for all sorts of class data and stuff.
One major problem was that Loader runs through its cycle twice, and it dumps the schema twice. The first time there’s no relationship information, because it hasn’t gotten it. The second time, after it gets the info and writes its relationship declarations… you still can’t get it! There’s a huge {_dump_storage} key in Loader’s $self, but if I wanted to parse that language, I would have stayed getting it from the files on disk. I honestly still don’t know what Loader does with all the relationship info after writing it out.
Well, that was dispiriting. So I gave up and just decided to get the info again and build my own relationship hash while iterating through the classes. It works pretty well.
One outstanding issue is how more subtly to handle relationships to other tables. Right now, if the relationship method is might_have Loader says
has 'posted_item' => (
isa => 'Test::Schema::PostedItem',
is => 'rw',
);
If the relationship method is has_many, Loader says
has 'discussion_topics' => (
isa => ArrayRef['Test::Schema::DiscussionTopic'],
is => 'rw',
);
It’s sort of a one-trick pony.
- BROWSE / IN TIMELINE
- « How I Learned to Write a Real Database Schema
- » Automatic CRUD in your Controllers
- BROWSE / IN object-oriented programming object-relation mapping perl
- « How I Learned to Write a Real Database Schema
- » Automatic CRUD in your Controllers
SPEAK / ADD YOUR COMMENT
Comments are moderated.

Recent Comments