Excerpts from Ovid's message of Tue Nov 03 11:01:12 -0500 2009: > When parsing documents, if my code finds more than one title in a document, > it's an error because we don't know which title is needed. The > user should be able to override this in the constructor and provide their own > title (this is actually true for several attributes): > > my $parser = Pod::Parser::Groffmom->new({title => $title}); > > > I tried trolling through the Class::MOP docs to find out if an attribute was > set in the constructor, but couldn't find anything. Seems the > other approach is using triggers or a BUILD method. What's the cleanest way > to do this?
Have 'title' have a lazy builder that consults 'possible titles from document' and dies if there's more than one. I'm assuming that parsing a document returns some data structure that you can keep around independent of the object's attributes. hdp.