MouseX::NativeTraits::HashRef(3pm) | User Contributed Perl Documentation | MouseX::NativeTraits::HashRef(3pm) |
MouseX::NativeTraits::HashRef - Helper trait for HashRef attributes
package Stuff; use Mouse; has 'options' => ( traits => ['Hash'], is => 'ro', isa => 'HashRef[Str]', default => sub { {} }, handles => { set_option => 'set', get_option => 'get', has_no_options => 'is_empty', num_options => 'count', delete_option => 'delete', pairs => 'kv', }, );
This module provides a Hash attribute which provides a number of hash-like operations.
These methods are implemented in MouseX::NativeTraits::MethodProvider::HashRef.
In list context return a list of values in the hash for the given keys. In scalar context returns the value for the last key specified.
for my $pair ( $object->options->pairs ) { print "$pair->[0] = $pair->[1]\n"; }
MouseX::NativeTraits
2022-06-16 | perl v5.34.0 |