perlquestion
Ovid
<p>Hi all,</p>
<p>I know there has to be a module doing what I want, but I can't quite seem to find it.</p>
<p>Essentially, I'm looking for a module which lets me build simple getter/setters with an optional validation callback.</p>
<dl>
<dt>Class::MethodMaker</dt>
<dd>Has an annoying habit of failing tests</dd>
<dt>Class::Accessor</dt>
<dd>Must inherit from it. I don't want that.</dd>
<dt>Class::Accessormaker</dt>
<dd>Nice but no validation</dd>
</dl>
<p>I want something like this:</p>
<code> use Class::BuildMethods
'name',
'rank' => { default => 'private' },
'date' => {
default => $some_date,
validate => &validate_date
};</code>
<p>Those the the things I'm doing over and over again. Constantly. That's what I want to abstract out but I'm not finding something which provides that in one easy to use module. Writing this is trivial but I'm loathe to upload <em>yet another friggin' module into the <tt>Class::</tt> namespace</em>. I know this module must be out there. What did I miss? :)</p>
<!-- Node text goes above. Div tags should contain sig only -->
<div class="pmsig"><div class="pmsig-17000">
<p>Cheers,<br />
<a href="/index.pl?node=Ovid&lastnode_id=1072">Ovid</a></p>
<p><small>New address of <a href="http://users.easystreet.com/ovid/cgi_course/">my CGI Course</a>.</small></p>
</div></div>