.\" 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 3pm" .TH MouseX::NativeTraits 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 \- Extend your attribute interfaces for Mouse .SH "VERSION" .IX Header "VERSION" This document describes MouseX::NativeTraits version 1.09. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& package MyClass; \& use Mouse; \& \& has mapping => ( \& traits => [\*(AqHash\*(Aq], \& is => \*(Aqrw\*(Aq, \& isa => \*(AqHashRef[Str]\*(Aq, \& default => sub { +{} }, \& handles => { \& exists_in_mapping => \*(Aqexists\*(Aq, \& ids_in_mapping => \*(Aqkeys\*(Aq, \& get_mapping => \*(Aqget\*(Aq, \& set_mapping => \*(Aqset\*(Aq, \& set_quantity => [ set => \*(Aqquantity\*(Aq ], \& }, \& ); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" While Mouse attributes provide a way to name your accessors, readers, writers, clearers and predicates, MouseX::NativeTraits provides commonly used attribute helper methods for more specific types of data. .PP As seen in the \*(L"\s-1SYNOPSIS\*(R"\s0, you specify the data structure via the \&\f(CW\*(C`traits\*(C'\fR parameter. These traits will be loaded automatically, so you need not load MouseX::NativeTraits explicitly. .PP This extension is compatible with Moose native traits, although it is not a part of Mouse core. .SH "PARAMETERS" .IX Header "PARAMETERS" .SS "handles" .IX Subsection "handles" This is like \f(CW\*(C`handles\*(C'\fR in \*(L"has\*(R" in Mouse, but only \s-1HASH\s0 references are allowed. Keys are method names that you want installed locally, and values are methods from the method providers (below). Currying with delegated methods works normally for \f(CW\*(C`handles\*(C'\fR. .SH "NATIVE TRAITS" .IX Header "NATIVE TRAITS" .SS "Array" .IX Subsection "Array" Common methods for array references. .PP .Vb 10 \& has \*(Aqqueue\*(Aq => ( \& traits => [\*(AqArray\*(Aq], \& is => \*(Aqro\*(Aq, \& isa => \*(AqArrayRef[Str]\*(Aq, \& default => sub { [] }, \& handles => { \& add_item => \*(Aqpush\*(Aq, \& next_item => \*(Aqshift\*(Aq, \& } \& ); .Ve .PP See MouseX::NativeTraits::ArrayRef. .SS "Hash" .IX Subsection "Hash" Common methods for hash references. .PP .Vb 11 \& 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_option => \*(Aqexists\*(Aq, \& } \& ); .Ve .PP See MouseX::NativeTraits::HashRef. .SS "Code" .IX Subsection "Code" Common methods for code references. .PP .Vb 9 \& has \*(Aqcallback\*(Aq => ( \& traits => [\*(AqCode\*(Aq], \& is => \*(Aqro\*(Aq, \& isa => \*(AqCodeRef\*(Aq, \& default => sub { sub { \*(Aqcalled\*(Aq } }, \& handles => { \& call => \*(Aqexecute\*(Aq, \& } \& ); .Ve .PP See MouseX::NativeTraits::CodeRef. .SS "Bool" .IX Subsection "Bool" Common methods for boolean values. .PP .Vb 12 \& has \*(Aqis_lit\*(Aq => ( \& traits => [\*(AqBool\*(Aq], \& is => \*(Aqrw\*(Aq, \& isa => \*(AqBool\*(Aq, \& default => 0, \& handles => { \& illuminate => \*(Aqset\*(Aq, \& darken => \*(Aqunset\*(Aq, \& flip_switch => \*(Aqtoggle\*(Aq, \& is_dark => \*(Aqnot\*(Aq, \& } \& ); .Ve .PP See MouseX::NativeTraits::Bool. .SS "String" .IX Subsection "String" Common methods for string operations. .PP .Vb 10 \& has text => ( \& traits => [\*(AqString\*(Aq], \& is => \*(Aqrw\*(Aq, \& isa => \*(AqStr\*(Aq, \& default => q{}, \& handles => { \& add_text => \*(Aqappend\*(Aq, \& replace_text => \*(Aqreplace\*(Aq, # or replace_globally \& } \& ); .Ve .PP See MouseX::NativeTraits::Str. .SS "Number" .IX Subsection "Number" Common numerical operations. .PP .Vb 10 \& has value => ( \& traits => [\*(AqNumber\*(Aq], \& is => \*(Aqro\*(Aq, \& isa => \*(AqInt\*(Aq, \& default => 5, \& handles => { \& set => \*(Aqset\*(Aq, \& add => \*(Aqadd\*(Aq, \& sub => \*(Aqsub\*(Aq, \& mul => \*(Aqmul\*(Aq, \& div => \*(Aqdiv\*(Aq, \& mod => \*(Aqmod\*(Aq, \& abs => \*(Aqabs\*(Aq, \& } \& ); .Ve .PP See MouseX::NativeTraits::Num. .SS "Counter" .IX Subsection "Counter" Methods for incrementing and decrementing a counter attribute. .PP .Vb 11 \& has counter => ( \& traits => [\*(AqCounter\*(Aq], \& is => \*(Aqro\*(Aq, \& isa => \*(AqNum\*(Aq, \& default => 0, \& handles => { \& inc_counter => \*(Aqinc\*(Aq, \& dec_counter => \*(Aqdec\*(Aq, \& reset_counter => \*(Aqreset\*(Aq, \& } \& ); .Ve .PP See MouseX::NativeTraits::Counter. .SH "DEPENDENCIES" .IX Header "DEPENDENCIES" Perl 5.6.2 or later. .SH "BUGS" .IX Header "BUGS" All complex software has bugs lurking in it, and this module is no exception. If you find a bug please either email me, or add the bug to cpan-RT. .SH "SEE ALSO" .IX Header "SEE ALSO" Mouse .PP MouseX::AttributeHelpers .PP Moose .PP Moose::Meta::Attribute::Native .PP MooseX::AttributeHelpers .SH "AUTHORS" .IX Header "AUTHORS" Goro Fuji (gfx) .PP This module is based on Moose native traits written by Stevan Little and others. .SH "LICENSE AND COPYRIGHT" .IX Header "LICENSE AND COPYRIGHT" Copyright (c) 2010, Goro Fuji (gfx), mostly based on Moose, which is (c) Infinity Interactive, Inc (). .PP This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic for details.