.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "MouseX::NativeTraits::HashRef 3pm" .TH MouseX::NativeTraits::HashRef 3pm "2022-06-16" "perl v5.34.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" MouseX::NativeTraits::HashRef \- Helper trait for HashRef attributes .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& package Stuff; \& use Mouse; \& \& has \*(Aqoptions\*(Aq => ( \& traits => [\*(AqHash\*(Aq], \& is => \*(Aqro\*(Aq, \& isa => \*(AqHashRef[Str]\*(Aq, \& default => sub { {} }, \& handles => { \& set_option => \*(Aqset\*(Aq, \& get_option => \*(Aqget\*(Aq, \& has_no_options => \*(Aqis_empty\*(Aq, \& num_options => \*(Aqcount\*(Aq, \& delete_option => \*(Aqdelete\*(Aq, \& pairs => \*(Aqkv\*(Aq, \& }, \& ); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This module provides a Hash attribute which provides a number of hash-like operations. .SH "PROVIDED METHODS" .IX Header "PROVIDED METHODS" These methods are implemented in MouseX::NativeTraits::MethodProvider::HashRef. .IP "\fBget($key, \f(CB$key2\fB, \f(CB$key3\fB...)\fR" 4 .IX Item "get($key, $key2, $key3...)" Returns values from the hash. .Sp 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. .IP "\fBset($key => \f(CB$value\fB, \f(CB$key2\fB => \f(CB$value2\fB...)\fR" 4 .IX Item "set($key => $value, $key2 => $value2...)" Sets the elements in the hash to the given values. .IP "\fBdelete($key, \f(CB$key2\fB, \f(CB$key3\fB...)\fR" 4 .IX Item "delete($key, $key2, $key3...)" Removes the elements with the given keys. .IP "\fBexists($key)\fR" 4 .IX Item "exists($key)" Returns true if the given key is present in the hash. .IP "\fBdefined($key)\fR" 4 .IX Item "defined($key)" Returns true if the value of a given key is defined. .IP "\fBkeys\fR" 4 .IX Item "keys" Returns the list of keys in the hash. .IP "\fBsorted_keys\fR" 4 .IX Item "sorted_keys" Returns the list of sorted keys in the hash. .IP "\fBvalues\fR" 4 .IX Item "values" Returns the list of values in the hash. .IP "\fBkv\fR" 4 .IX Item "kv" Returns the key/value pairs in the hash as an array of array references. .Sp .Vb 3 \& for my $pair ( $object\->options\->pairs ) { \& print "$pair\->[0] = $pair\->[1]\en"; \& } .Ve .IP "\fBelements\fR" 4 .IX Item "elements" Returns the key/value pairs in the hash as a flattened list. .IP "\fBclear\fR" 4 .IX Item "clear" Resets the hash to an empty value, like \f(CW\*(C`%hash = ()\*(C'\fR. .IP "\fBcount\fR" 4 .IX Item "count" Returns the number of elements in the hash. Also useful for not empty: \&\f(CW\*(C`has_options => \*(Aqcount\*(Aq\*(C'\fR. .IP "\fBis_empty\fR" 4 .IX Item "is_empty" If the hash is populated, returns false. Otherwise, returns true. .IP "\fBaccessor\fR" 4 .IX Item "accessor" If passed one argument, returns the value of the specified key. If passed two arguments, sets the value of the specified key. .SH "METHODS" .IX Header "METHODS" .IP "\fBmeta\fR" 4 .IX Item "meta" .PD 0 .IP "\fBmethod_provider_class\fR" 4 .IX Item "method_provider_class" .IP "\fBhelper_type\fR" 4 .IX Item "helper_type" .PD .SH "SEE ALSO" .IX Header "SEE ALSO" MouseX::NativeTraits