=head1 DESCRIPTION
-While L<Moose> attributes provide you with a way to name your accessors,
-readers, writers, clearers and predicates, this library provides commonly
+While L<Moose> attributes provide a way to name your accessors, readers,
+writers, clearers and predicates, this library provides commonly
used attribute helper methods for more specific types of data.
-As seen in the L</SYNOPSIS>, you specify the extension via the
+As seen in the L</SYNOPSIS>, you specify the data structure via the
C<trait> parameter. Available meta classes are below; see L</METHOD PROVIDERS>.
This module used to exist as the L<MooseX::AttributeHelpers> extension. It was
Common numerical operations.
has 'integer' => (
- metaclass => 'Number',
+ traits => ['Number'],
is => 'ro',
isa => 'Int',
default => 5,
- handles => {
+ handles => {
set => 'set',
add => 'add',
sub => 'sub',
Common methods for string operations.
has 'text' => (
- metaclass => 'String',
+ traits => ['String'],
is => 'rw',
isa => 'Str',
default => q{},
- handles => {
+ handles => {
add_text => 'append',
replace_text => 'replace',
}
Methods for incrementing and decrementing a counter attribute.
has 'counter' => (
- traits => ['Counter'],
+ traits => ['Counter'],
is => 'ro',
isa => 'Num',
default => 0,
Common methods for boolean values.
has 'is_lit' => (
- traits => ['Bool'],
+ traits => ['Bool'],
is => 'rw',
isa => 'Bool',
default => 0,
}
);
-
=item L<Hash|Moose::Meta::Attribute::Native::Trait::Hash>
Common methods for hash references.
isa => 'HashRef[Str]',
default => sub { {} },
handles => {
- set_option => 'set',
- get_option => 'get',
- has_option => 'exists',
+ set_option => 'set',
+ get_option => 'get',
+ has_option => 'exists',
}
);
is => 'ro',
isa => 'ArrayRef[Str]',
default => sub { [] },
- handles => {
- add_item => 'push'
+ handles => {
+ add_item => 'push',
next_item => 'shift',
}
);