On Tue, Nov 03, 2009 at 08:01:12AM -0800, Ovid wrote:
> 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?
Moose/CMOP doesn't make this distinction (since it's rarely necessary,
and would just complicate things). I think doing this setup in BUILD
would probably be the cleanest/easiest way, but you could probably
fiddle something into working with initializer (from
Class::MOP::Attribute) if you tried a bit. Trigger probably won't help,
since it's called both during construction and when setting.
-doy