2009/6/17 Johannes Plunien <[email protected]> replied: > has 'options' => ( > > # this is the part you're missing: > auto_deref => 1, > > is => 'ro', > isa => 'HashRef[Str]', > metaclass => 'Collection::ImmutableHash', > isa => 'HashRef[Str]', > builder => '_build_options', > provides => { > 'keys' => 'all_option_keys', > 'get' => 'get_option', > }, > ); > > # ... > > my %hsh = $obj->options; > > > See comment in code above and perldoc: > http://search.cpan.org/dist/Moose/lib/Moose/Manual/Attributes.pod#The_auto_deref_option
I see. I'd read the recommandation there to use AttributeHelpers instead. But you're right, this is cleaner than my version. Still, it makes for a difference between the ArrayRef and HashRef API: for an ArrayRef, I can work with _only_ the provided methods, and don't need 'is' and 'auto_deref'. (now I'm certain I'm nitpicking). Cheers, -- Jurgen Pletinckx
