Hi,

On 17.06.2009, at 09:48, Jurgen Pletinckx wrote:

my %hsh = %{$obj->options}; # strike 2: dereference

which is somewhat kludgier. And feels close to vanilla perl 5. I
thought the 'kv' provided method would do this, but this seems
to return an array of pairs, rather than a flat list.

Am I missing something, or just picking nits, or is there an
opportunity to slightly improve the API there?

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

Cheers,
plu

--
Johannes Plunien | mailto:p...@pqpq.de | http://www.pqpq.de/contact/

Reply via email to