Take a look at
http://search.cpan.org/src/SARTAK/MooseX-AttributeHelpers-0.12/t/002_basic_array.t - that's the test that exercises the AttributeHelper that provides an array. You kinda have to look at it sideways a bit, but everything's there. The rosetta stone might be at the bottom.
This does bring up an interesting question - how much of this do you really want Moose to do? This isn't idle speculation, either. I wrote some of the initial pieces of Moose with stvn and I think it's a phenomenal piece of work and should be used by most people in most places. Except, I've never used it in either work, OSS, or play. Part of that is I am completely comfortable with Perl's OO systems, having written about 4 myself and debugged several others. Part of that is that most of my work predates when Moose was actually usable. Part of that, though, is that I just don't drink that much koolaid. At some point, the syntactic sugar just gets to be too much and it's just simpler to go to another language like Ruby, Python, Javascript, or Smalltalk. Even stvn would agree that some of the really esoteric bits of Moose aren't ever going to be usable. Sometimes, a blessed hashref with cut'n'paste mutators is the right way to go.
sub foo {
my $self = shift;
$self->{foo} = shift if @_;
return $self->{foo};
}
I'm not arguing against frameworks. I love them. I'm just saying that sometimes, a framework is inappropriate and you should learn to tell when that is.
My criteria for good software:
- Does it work?
- Can someone else come in, make a change, and be reasonably certain no bugs were introduced?