in reply to Moose question

You might want to look at MooseX::AttributeHelpers. It lets you create handlers for hashrefs and arrayref types (among other types), something like this (based on the example in the documentation):

has 'options' => ( metaclass => 'Collection::Hash', is => 'rw', isa => 'HashRef[Str]', default => sub { {} }, provides => { exists => 'option_exists', kv => 'options', get => 'get_option', set => 'set_option', clear => 'clear_options', accessor => 'option', }, curries => { set => { set_quantity => [ 'quantity' ] } } );

This lets you use the get_option and set_option methods, or option to use accessor syntax like $obj->option('test') to get an option or $obj->option( test => 'value') to set the value, and clear_options clears the whole hash. The curries hash lets you pass parameters to the handler methods in object methods, e.g. $obj->set_quantity(42) (using the code above) would be equivalent to $obj->set_option(quantity => 42)

See MooseX::AttributeHelpers::MethodProvider::Hash for the options available for hash objects.